about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-11-17 15:39:39 -0600
committermultiple creatures <dev@multiple-creature.party>2019-11-17 15:39:39 -0600
commitf01f38d0ea568592ea614d4e557d937b5ccfe287 (patch)
tree48a0b5a35d474065905a7815db22f94b6fb05a66
parent04165369fd6e317fc5a2768a49876ebc8a11889d (diff)
Prefix zero-width space before lines with space characters to preserve their formatting on other servers.
-rw-r--r--app/services/post_status_service.rb5
1 files changed, 5 insertions, 0 deletions
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