From 043862f4118a9ee5e6708ff9c144fa9e668ee06d Mon Sep 17 00:00:00 2001 From: Eugen Date: Thu, 13 Apr 2017 19:23:36 +0200 Subject: [PATCH] Fix #1609, fix #1628 - Revert #1397 (#1700) When transmitting data in a HTML-encoded element like , relying on newlines being preserved is not wise, since HTML by itself does not care for newlines - it cares for

and
Additional fix: reset NSFW toggle after sending toot --- app/assets/javascripts/components/components/status_content.jsx | 2 +- app/assets/javascripts/components/reducers/compose.jsx | 1 + app/lib/formatter.rb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/components/components/status_content.jsx b/app/assets/javascripts/components/components/status_content.jsx index 9cf03bb3256..c7eefcaf508 100644 --- a/app/assets/javascripts/components/components/status_content.jsx +++ b/app/assets/javascripts/components/components/status_content.jsx @@ -92,7 +92,7 @@ const StatusContent = React.createClass({ const { status } = this.props; const { hidden } = this.state; - const content = { __html: emojify(status.get('content')).replace(/\n/g, '') }; + const content = { __html: emojify(status.get('content')) }; const spoilerContent = { __html: emojify(escapeTextContentForBrowser(status.get('spoiler_text', ''))) }; const directionStyle = { direction: 'ltr' }; diff --git a/app/assets/javascripts/components/reducers/compose.jsx b/app/assets/javascripts/components/reducers/compose.jsx index 86974239bee..7349cc351d4 100644 --- a/app/assets/javascripts/components/reducers/compose.jsx +++ b/app/assets/javascripts/components/reducers/compose.jsx @@ -67,6 +67,7 @@ function clearAll(state) { map.set('is_submitting', false); map.set('in_reply_to', null); map.set('privacy', state.get('default_privacy')); + map.set('sensitive', false); map.update('media_attachments', list => list.clear()); }); }; diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index b6d371ed2d6..64349e68ebc 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -15,6 +15,7 @@ class Formatter html = status.text html = encode(html) html = simple_format(html, {}, sanitize: false) + html = html.gsub(/\n/, '') html = link_urls(html) html = link_mentions(html, status.mentions) html = link_hashtags(html)