Firestore - Sanitizing Text Area Input?

寵の児 提交于 2020-08-23 03:53:17

问题


I see in the Writing conditions for Cloud Firestore Security Rules documentation that a (server side) custom function can be run against new writes. My question is: do I even need to worry about sanitizing textarea user input before writing/saving that to FireStore, or does Firestore automatically do this?

If I need to sanitize user input, what would a javascript function look like to do that? What characters should I disallow or remove from the string? Thanks in advance.


回答1:


Firestore does not automatically do any filtering of input. If you want to filter the input, you will have to do so in your own code and/or security rules.

The exact rules depend on your specific needs. The most common things I see are length restrictions, and things like email or phone number validations. More complex rules are definitely possible, but many developers at some point prefer using a Cloud Function to do the sanitization.



来源:https://stackoverflow.com/questions/51690918/firestore-sanitizing-text-area-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!