diff --git a/core/includes/batch.inc b/core/includes/batch.inc index bfd6d8e..96d22fd 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -46,6 +46,8 @@ function _batch_page(Request $request) { } } // Restore safe strings from previous batches. + // @todo Ensure we are not storing an excessively large string list in: + // https://www.drupal.org/node/2295823 if (!empty($batch['safe_strings'])) { SafeMarkup::setMultiple($batch['safe_strings']); } @@ -485,6 +487,8 @@ function _batch_finished() { function _batch_shutdown() { if ($batch = batch_get()) { // Update safe strings. + // @todo Ensure we are not storing an excessively large string list in: + // https://www.drupal.org/node/2295823 $batch['safe_strings'] = SafeMarkup::getAll(); \Drupal::service('batch.storage')->update($batch); } diff --git a/core/includes/form.inc b/core/includes/form.inc index 793bccf..4029a1e 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -3298,6 +3298,8 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU } // Store safe strings. + // @todo Ensure we are not storing an excessively large string list in: + // https://www.drupal.org/node/2295823 $batch['safe_strings'] = SafeMarkup::getAll(); // Store the batch. diff --git a/core/lib/Drupal/Component/Utility/SafeMarkup.php b/core/lib/Drupal/Component/Utility/SafeMarkup.php index e1c7524..4043da3 100644 --- a/core/lib/Drupal/Component/Utility/SafeMarkup.php +++ b/core/lib/Drupal/Component/Utility/SafeMarkup.php @@ -12,14 +12,38 @@ * * @todo Add detailed documentation about how to use SafeMarkup and how it is * handled during rendering and in the theme layer. + * + * @see sanitization */ class SafeMarkup { + /** + * The list of safe strings. + * + * @var array + */ protected static $safeStrings = array(); /** * Adds a string to a list of strings marked as secure. * + * This method is for internal use. Do not use it to prevent escaping of + * markup; instead, use the appropriate + * @link sanitization sanitization functions @endlink or the + * @link theme_render theme and render systems @endlink so that the output + * can be themed and altered properly. + * + * This marks strings as secure for the entire page render, not just the code + * or element that set it. Therefore, only complete strings should be + * marked as safe (never partial markup). For example, you should never do: + * @code + * SafeMarkup::set("'"); + * @endcode + * or: + * @code + * SafeMarkup::set('