From f01f38d0ea568592ea614d4e557d937b5ccfe287 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Sun, 17 Nov 2019 15:39:39 -0600 Subject: Prefix zero-width space before lines with space characters to preserve their formatting on other servers. --- app/services/post_status_service.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/services') diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index e2da4b358..45d66831b 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -145,6 +145,10 @@ class PostStatusService < BaseService @text.gsub!("\ufdd6", "#") end + def protect_leading_spaces + @text.gsub!(/^ /, "\u200b ") + end + def preprocess_attributes! if @text.blank? && @options[:spoiler_text].present? @text = '.' @@ -153,6 +157,7 @@ class PostStatusService < BaseService set_footer_from_i_am extract_tags + protect_leading_spaces set_local_only set_initial_visibility limit_visibility_if_silenced -- cgit