FIX: Disallow zero-width and other non-printing characters in tags (#11546)

This commit is contained in:
Daniel Waterworth 2020-12-22 09:27:37 -06:00 committed by GitHub
parent c9381beb9c
commit a4fb28ccd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -444,7 +444,8 @@ module DiscourseTagging
tag = tag.dup
tag.downcase! if SiteSetting.force_lowercase_tags
tag.strip!
tag.gsub!(/\s+/, '-')
tag.gsub!(/[[:space:]]+/, '-')
tag.gsub!(/[^[:word:][:punct:]]+/, '')
tag.squeeze!('-')
tag.gsub!(TAGS_FILTER_REGEXP, '')
tag[0...SiteSetting.max_tag_length]

View File

@ -546,6 +546,10 @@ describe DiscourseTagging do
SiteSetting.force_lowercase_tags = false
expect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")
end
it "removes zero-width spaces" do
expect(DiscourseTagging.clean_tag("hel\ufefflo")).to eq("hello")
end
end
end