Reputation: 13507
Webapp has, say, comments form.
If user is inputting something like:
"Comment about 'topic" (single quote is not closed)
This brakes node-postgres
queries.
What is the simplest way to escape/comment-out/convert-to-unicode all the special characters? But at the same time, make it easy to render on the page after all.
For example, backslash would successfully comment-out the single quote. But i'm sure, there are much more special characters, which could break the pg queries. Is there some commonly used script/module to make strings safe?
Upvotes: 0
Views: 746
Reputation: 13507
node-postgres
has such method already:
https://github.com/brianc/node-postgres/wiki/Prepared-Statements
Upvotes: 1