Commit 6cb0e3fc authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

[gh-636] Convert new lines to br tag with plain text processor

parent 670ac1a5
......@@ -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:
......
......@@ -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/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]));
}
/**
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment