diff --git a/README.md b/README.md index fb118e8fb2519e73d4033a27d4604df6dabb02ae..917c2a69e700aa7673b2c192afedce61d5d52524 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,9 @@ In this example the web root is /Library/WebServer/Documents and Apache runs as - theme_image_formatter ignores attributes so classes can't be added to an image in a theme (needed for photo frame). See http://drupal.org/node/1025796#comment-4298698 and http://drupal.org/files/issues/1025796.patch + * modules/field/modules/text/text.module + + - Add nl2br() on Plain Text processor. See http://drupal.org/node/1152216#comment-7174876 ## Hacks of Contrib modules: diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module index d73814faaafa007f2f13499616ecd17edcf24b7f..9ba0051fce762218f9e34d1309fc776c0ac95b04 100644 --- a/modules/field/modules/text/text.module +++ b/modules/field/modules/text/text.module @@ -284,7 +284,9 @@ function text_field_formatter_view($entity_type, $entity, $field, $instance, $la case 'text_plain': foreach ($items as $delta => $item) { - $element[$delta] = array('#markup' => strip_tags($item['value'])); + // The text value has no text format assigned to it, so the user input + // should equal the output, including newlines. + $element[$delta] = array('#markup' => nl2br(check_plain($item['value']))); } break; } @@ -316,7 +318,12 @@ function _text_sanitize($instance, $langcode, $item, $column) { if (isset($item["safe_$column"])) { return $item["safe_$column"]; } - return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], $langcode) : check_plain($item[$column]); + if ($instance['settings']['text_processing']) { + return check_markup($item[$column], $item['format'], $langcode); + } + // Escape all HTML and retain newlines. + // @see text_field_formatter_view() + return nl2br(check_plain($item[$column])); } /** diff --git a/patches/text-plain-1152216-24.patch b/patches/text-plain-1152216-24.patch new file mode 100644 index 0000000000000000000000000000000000000000..d48b6bdaf42e54fed1f352a10fb7b2530c77dcfc --- /dev/null +++ b/patches/text-plain-1152216-24.patch @@ -0,0 +1,29 @@ +diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module +index d73814f..9ba0051 100644 +--- a/modules/field/modules/text/text.module ++++ b/modules/field/modules/text/text.module +@@ -284,7 +284,9 @@ function text_field_formatter_view($entity_type, $entity, $field, $instance, $la + + case 'text_plain': + foreach ($items as $delta => $item) { +- $element[$delta] = array('#markup' => strip_tags($item['value'])); ++ // The text value has no text format assigned to it, so the user input ++ // should equal the output, including newlines. ++ $element[$delta] = array('#markup' => nl2br(check_plain($item['value']))); + } + break; + } +@@ -316,7 +318,12 @@ function _text_sanitize($instance, $langcode, $item, $column) { + if (isset($item["safe_$column"])) { + return $item["safe_$column"]; + } +- return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], $langcode) : check_plain($item[$column]); ++ if ($instance['settings']['text_processing']) { ++ return check_markup($item[$column], $item['format'], $langcode); ++ } ++ // Escape all HTML and retain newlines. ++ // @see text_field_formatter_view() ++ return nl2br(check_plain($item[$column])); + } + + /**