LocalData / localdata-api

API/server for LocalData
http://localdata.com/
BSD 3-Clause "New" or "Revised" License
20 stars 14 forks source link

Avoid invalid MongoDB sub-field names when caching stats #295

Closed prashtx closed 8 years ago

prashtx commented 9 years ago

MongoDB does not allow field names that start with $ or contain .. We can encounter these when caching the stats data, where we use survey answers as keys (with tallies as the values) and might see free-form text answers. To be safe, we escape both of those characters anywhere in the field name, along with \, so we can go back and forth easily.

/cc @hampelm