FIX: strip zero width spaces from topic title

This commit is contained in:
Arpit Jalan 2018-02-20 23:52:36 +05:30
parent 677e126fbf
commit a4bc54a686
2 changed files with 9 additions and 1 deletions

View File

@ -17,7 +17,8 @@ class TextCleaner
remove_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 TextCleaner
text = normalize_whitespaces(text)
# Strip whitespaces
text.strip! if opts[:strip_whitespaces]
# Strip zero width spaces
text.gsub!(/\u200b/, '') if opts[:strip_zero_width_spaces]
text
end

View File

@ -159,6 +159,11 @@ describe TextCleaner do
expect(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" do
before { SiteSetting.title_prettify = true }