Module: check_mk
Branch: master
Commit: 48b6e853ffede5208f5a4e9ab3c06cae96083ac1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=48b6e853ffede5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Oct 16 16:34:04 2018 +0200
6785 FIX Fixed truncating leading new lines in text area input fields
When a multi line text area was used for editing a text that starts with an
empty line, the leading empty line was stripped off during rendering of the
dialog.
This affected, for example, the body template of ASCII mail notifications.
CMK-930
Change-Id: I11a991a298629731cbb584f2169a0b96556ebe93
---
.werks/6785 | 15 +++++++++++++++
cmk/gui/htmllib.py | 13 +++++++++++++
2 files changed, 28 insertions(+)
diff --git a/.werks/6785 b/.werks/6785
new file mode 100644
index 0000000..1cb01de
--- /dev/null
+++ b/.werks/6785
@@ -0,0 +1,15 @@
+Title: Fixed truncating leading new lines in text area input fields
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1539700301
+
+When a multi line text area was used for editing a text that starts with an
+empty line, the leading empty line was stripped off during rendering of the
+dialog.
+
+This affected, for example, the body template of ASCII mail notifications.
diff --git a/cmk/gui/htmllib.py b/cmk/gui/htmllib.py
index 17fc4e5..ddc9f59 100644
--- a/cmk/gui/htmllib.py
+++ b/cmk/gui/htmllib.py
@@ -2420,6 +2420,19 @@ class html(HTMLGenerator):
attrs["cols"] = cols
attrs["name"] = varname
+ # Fix handling of leading newlines
(
https://www.w3.org/TR/html5/syntax.html#element-restrictions)
+ #
+ # """
+ # A single newline may be placed immediately after the start tag of pre
+ # and textarea elements. This does not affect the processing of the
+ # element. The otherwise optional newline must be included if the
+ # element’s contents themselves start with a newline (because otherwise
+ # the leading newline in the contents would be treated like the
+ # optional newline, and ignored).
+ # """
+ if value and value.startswith("\n"):
+ value = "\n" + value
+
if error:
self.open_x(class_="inputerror")
self.write_html(self._render_content_tag("textarea", value, **attrs))