Active
Project:
Drupal core
Version:
main
Component:
documentation
Priority:
Major
Category:
Task
Assigned:
Reporter:
Created:
26 Sep 2015 at 16:17 UTC
Updated:
8 Jan 2026 at 00:24 UTC
Jump to comment: Most recent
SafeMarkup, TranslatedString etc. needs an overview, so new people can understand it from an high level.
The follow is from the current SafeMarkup class docblock,
* This class should be limited to internal use only. Module developers should
* instead use the appropriate
* @link sanitization sanitization functions @endlink or the
* @link theme_render theme and render systems @endlink so that the output can
* can be themed, escaped, and altered properly.
Since this was written core has moved on a lot and now SafeMarkup contains most of the sanitisation methods. Also considering the importance of using SafeMarkup functions correctly I think the documentation should have helpful examples for developers.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
xjmComment #3
xjmReferences that need review:
https://www.drupal.org/node/2296163 and its many related CRs (some linked, some not linked)
https://www.drupal.org/node/2489544 (Drupal 7 version here https://www.drupal.org/writing-secure-code) https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...
https://api.drupal.org/api/drupal/core%21core.api.php/group/best_practic...
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...
https://api.drupal.org/api/drupal/core%21includes%21common.inc/group/san...
https://www.drupal.org/node/2357633
https://www.drupal.org/node/28984
https://www.drupal.org/node/263002
https://www.drupal.org/node/101495
Comment #4
xjmhttps://www.drupal.org/node/299085
https://www.drupal.org/node/13220
https://www.drupal.org/node/322774
https://www.drupal.org/node/322732
Comment #5
catchNot sure this can be finished until #2570431: Document that certain (non-"href") attribute values in t() and SafeMarkup::format() are not supported and may be insecure lands.
Also #2575615: Introduce HtmlEscapedText and remove SafeMarkup::setMultiple() and SafeMarkup::getAll() and remove the static safeStrings list.
That shouldn't stop people working on it, but it feels like those issues are necessary to get to a baseline of stability in core.
Comment #6
xjmhttps://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Menu%21me... has some text about safeness that needs to be reviewed.
Comment #7
xjmComment #9
alexpottComment #22
smustgrave commentedwhat's left for this one?
Comment #25
owenpm3 commentedLooks like this has changed a lot in 10 years, who would've guessed. I think the main item of explaining markup sanitization is covered with the several other updates since. Examples of code use and deeper documentation on it would still be great to have.
From what I can see in the API docs, the following form some of the basis for sanitizing markup:
The theme render docs look pretty thorough--it might help to either reference those or write up some example use cases for the different Markup classes.