A platform for community discussion. Free, open, simple.
FIX: Disallow zero-width and other non-printing characters in tags (#11546)
Daniel Waterwortha4fb28ccd89c
diff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rbindex f8e2213f4f8..f2a4e4be016 100644--- a/lib/discourse_tagging.rb+++ b/lib/discourse_tagging.rb@@ -444,7 +444,8 @@ module DiscourseTaggingtag = tag.duptag.downcase! if SiteSetting.force_lowercase_tagstag.strip!- tag.gsub!(/\s+/, '-')+ tag.gsub!(/[[:space:]]+/, '-')+ tag.gsub!(/[^[:word:][:punct:]]+/, '')tag.squeeze!('-')tag.gsub!(TAGS_FILTER_REGEXP, '')tag[0...SiteSetting.max_tag_length]diff --git a/spec/components/discourse_tagging_spec.rb b/spec/components/discourse_tagging_spec.rbindex 3af0784ec2f..ab96f4731cb 100644--- a/spec/components/discourse_tagging_spec.rb+++ b/spec/components/discourse_tagging_spec.rb@@ -546,6 +546,10 @@ describe DiscourseTagging doSiteSetting.force_lowercase_tags = falseexpect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")end++ it "removes zero-width spaces" do+ expect(DiscourseTagging.clean_tag("hel\ufefflo")).to eq("hello")+ endendend