diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-10-25 18:19:24 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-10-28 10:48:58 +0300 |
commit | ee4dd39814cbd9907b63a0a9f02919e952fe453c (patch) | |
tree | 0b3b1f31fc8140bc42807e6717a4a7f6e7c0d6bb | |
parent | 6f1183b35c7ed08c71f81886012f9573b12b5561 (diff) |
Fix unnecessary line breaks in quoted reply text
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rwxr-xr-x | lib/Service/Html.php | 4 | ||||
-rw-r--r-- | src/components/MessagePlainTextBody.vue | 17 | ||||
-rw-r--r-- | tests/Service/HtmlTest.php | 2 |
3 files changed, 18 insertions, 5 deletions
diff --git a/lib/Service/Html.php b/lib/Service/Html.php index 8c805abc4..0c725a178 100755 --- a/lib/Service/Html.php +++ b/lib/Service/Html.php @@ -98,12 +98,12 @@ class Html { $signature = null; $parts = explode("-- \r\n", $body); if (count($parts) > 1) { - $signature = nl2br(array_pop($parts)); + $signature = array_pop($parts); $body = implode("-- \r\n", $parts); } return [ - nl2br($body), + $body, $signature ]; } diff --git a/src/components/MessagePlainTextBody.vue b/src/components/MessagePlainTextBody.vue index 738e544ef..2639aa014 100644 --- a/src/components/MessagePlainTextBody.vue +++ b/src/components/MessagePlainTextBody.vue @@ -1,7 +1,7 @@ <template> <div> - <div id="mail-content" v-html="body"></div> - <div v-if="signature" class="mail-signature" v-html="signature"></div> + <div id="mail-content" v-html="htmlBody"></div> + <div v-if="signature" class="mail-signature" v-html="htmlSignature"></div> </div> </template> @@ -18,6 +18,19 @@ export default { default: () => undefined, }, }, + computed: { + htmlBody() { + return this.nl2br(this.body) + }, + htmlSignature() { + return this.nl2br(this.signature) + }, + }, + methods: { + nl2br(str) { + return str.replace(/(\r\n|\n\r|\n|\r)/g, '<br />') + }, + }, } </script> diff --git a/tests/Service/HtmlTest.php b/tests/Service/HtmlTest.php index 8e4272c9f..8f5d9cff0 100644 --- a/tests/Service/HtmlTest.php +++ b/tests/Service/HtmlTest.php @@ -82,7 +82,7 @@ class HtmlTest extends TestCase { return [ ['abc', null, 'abc'], ['abc', 'def', "abc-- \r\ndef"], - ["abc-- <br />\r\ndef", 'ghi', "abc-- \r\ndef-- \r\nghi"], + ["abc-- \r\ndef", 'ghi', "abc-- \r\ndef-- \r\nghi"], ]; } |