I am writing a custom module for Drupal 6 that programmatically creates a node using node_save().
The various custom node fields come from user input - is it necessary to manually escape these fields, or will node_save() take care of that for me?
|
feedback
|
|
If by escaping you mean using Imagine what would happen if you call In Writing secure code, you can read the following text:
As you see, the page about writing secure code doesn't say to escape the text being saved, but only text being output, when the text has been entered from users, in a way or in another. An example of text entered from a user is the username or the signature associated to user accounts, the node title, or the node body. About SQL injection, you just need to use placeholders in you queries; Drupal database functions escapes the content of the placeholders, which would not be possible if you write a query like the following one, for example:
The "Writing secure code" reports:
| |||||||||||||||||
feedback
|
|
I quickly glanced through node_save and there is no escaping done on the $node object before drupal_write_record, drupal_write_record does no escaping either so even if I've overlooked something your best bet is to escape. Better safe than sorry! | |||
|
feedback
|