5

Hi I see the word "sanitized" quite often in Drupal API documentation.

For example, this page: theme_username($variables)

$variables An associative array containing:

account: The user object to format.

name: The user's name, sanitized.

extra: Additional text to append to the user's name, sanitized.

What does sanitized mean in the context?

8

'Sanitization' is the removal of malicious data from user input, such as form submissions or maybe more simply...

The cleaning of user input to avoid code-conflicts (duplicate ids for instance), security issues (xss codes etc), or other issues that might arise from non-standardized input & human error/deviance.

Depending on the context, sanitization will take on a few different forms. Could be as simple as removing vulgarities & odd symbols from text to removing SQL injection attempts and other malicious code intrusion attempts.

You can get the idea of what Sanitization is generalized to drupal core by looking at: http://api.drupal.org/api/drupal/includes--common.inc/group/sanitization/7

For instance, the check_plain() function will:

Encode special characters in a plain-text string for display as HTML.

Also validates strings as UTF-8 to prevent cross site scripting attacks on Internet Explorer 6.

or filter_xss() which:

Filters an HTML string to prevent cross-site-scripting (XSS) vulnerabilities.

3

The key idea with Drupal input handling is that any data is accepted from the user, but we make sure to output to the screen (or use in database queries) only "sanitized" data - which will do no damage, provide no XSS and related opportunities, etc.

To understand the excellent answer above you need to make sure you understand that strategy. You may be interested in reading the excellent little book "Cracking Drupal" or the resources from http://crackingdrupal.com/.

2

Two meanings here, one is properly encoding characters like & or ', the other to prevent code injection.

0

'Sanitization' is the removal of malicious data from user input, such as form submissions

  • 2
    Welcome to Drupal Answers. This is just a short version of the answer that has been expected, and adds nothing to the site. When you answer, make sure your answer contributes something. – Free Radical Mar 19 '15 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.