A platform for community discussion. Free, open, simple.
FIX: strip zero width spaces from topic title
Arpit Jalana4bc54a6866c
diff --git a/lib/text_cleaner.rb b/lib/text_cleaner.rbindex 31ff605cef3..0914fe88881 100644--- a/lib/text_cleaner.rb+++ b/lib/text_cleaner.rb@@ -17,7 +17,8 @@ class TextCleanerremove_all_periods_from_the_end: SiteSetting.title_prettify,remove_extraneous_space: SiteSetting.title_prettify && SiteSetting.default_locale == "en",fixes_interior_spaces: true,- strip_whitespaces: true+ strip_whitespaces: true,+ strip_zero_width_spaces: true}end@@ -47,6 +48,8 @@ class TextCleanertext = normalize_whitespaces(text)# Strip whitespacestext.strip! if opts[:strip_whitespaces]+ # Strip zero width spaces+ text.gsub!(/\u200b/, '') if opts[:strip_zero_width_spaces]textenddiff --git a/spec/components/text_cleaner_spec.rb b/spec/components/text_cleaner_spec.rbindex 8a25c29de82..e4a4dd2a9fc 100644--- a/spec/components/text_cleaner_spec.rb+++ b/spec/components/text_cleaner_spec.rb@@ -159,6 +159,11 @@ describe TextCleaner doexpect(TextCleaner.clean_title(" \t Hello there \n ")).to eq("Hello there")end+ it "strips zero width spaces" do+ expect(TextCleaner.clean_title("Hello there")).to eq("Hello there")+ expect(TextCleaner.clean_title("Hello there").length).to eq(11)+ end+context "title_prettify site setting is enabled" dobefore { SiteSetting.title_prettify = true }