FIX: Disallow zero-width and other non-printing characters in tags (#11546)
This commit is contained in:
parent
c9381beb9c
commit
a4fb28ccd8
|
@ -444,7 +444,8 @@ module DiscourseTagging
|
||||||
tag = tag.dup
|
tag = tag.dup
|
||||||
tag.downcase! if SiteSetting.force_lowercase_tags
|
tag.downcase! if SiteSetting.force_lowercase_tags
|
||||||
tag.strip!
|
tag.strip!
|
||||||
tag.gsub!(/\s+/, '-')
|
tag.gsub!(/[[:space:]]+/, '-')
|
||||||
|
tag.gsub!(/[^[:word:][:punct:]]+/, '')
|
||||||
tag.squeeze!('-')
|
tag.squeeze!('-')
|
||||||
tag.gsub!(TAGS_FILTER_REGEXP, '')
|
tag.gsub!(TAGS_FILTER_REGEXP, '')
|
||||||
tag[0...SiteSetting.max_tag_length]
|
tag[0...SiteSetting.max_tag_length]
|
||||||
|
|
|
@ -546,6 +546,10 @@ describe DiscourseTagging do
|
||||||
SiteSetting.force_lowercase_tags = false
|
SiteSetting.force_lowercase_tags = false
|
||||||
expect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")
|
expect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "removes zero-width spaces" do
|
||||||
|
expect(DiscourseTagging.clean_tag("hel\ufefflo")).to eq("hello")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue