Skip to content

A platform for community discussion. Free, open, simple.

Revert "FIX: Sanitize tags before creation"

David Taylor0dd717e641e4
diff --git a/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6 b/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
index 07825a3bca0..5484dbae8e2 100644
--- a/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
+++ b/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
@@ -214,6 +214,28 @@ export default ComboBox.extend(TagsMixin, {
this.destroyTags(tags);
},
+ _sanitizeContent(content, property) {
+ switch (typeof content) {
+ case "string":
+ // See lib/discourse_tagging#clean_tag.
+ return content
+ .trim()
+ .replace(/\s+/, "-")
+ .replace(/[\/\?#\[\]@!\$&'\(\)\*\+,;=\.%\\`^\s|\{\}"<>]+/, "")
+ .substring(0, this.siteSettings.max_tag_length);
+ default:
+ return get(content, this.get(property));
+ }
+ },
+
+ valueForContentItem(content) {
+ return this._sanitizeContent(content, "valueAttribute");
+ },
+
+ _nameForContent(content) {
+ return this._sanitizeContent(content, "nameProperty");
+ },
+
actions: {
onSelect(tag) {
this.set("tags", makeArray(this.get("tags")).concat(tag));
diff --git a/app/assets/javascripts/select-kit/mixins/tags.js.es6 b/app/assets/javascripts/select-kit/mixins/tags.js.es6
index f6bd407c385..0f0bef09ad4 100644
--- a/app/assets/javascripts/select-kit/mixins/tags.js.es6
+++ b/app/assets/javascripts/select-kit/mixins/tags.js.es6
@@ -68,20 +68,5 @@ export default Ember.Mixin.create({
}
return true;
- },
-
- createContentFromInput(input) {
- // See lib/discourse_tagging#clean_tag.
- var content = input
- .trim()
- .replace(/\s+/, "-")
- .replace(/[\/\?#\[\]@!\$&'\(\)\*\+,;=\.%\\`^\s|\{\}"<>]+/, "")
- .substring(0, this.siteSettings.max_tag_length);
-
- if (this.siteSettings.force_lowercase_tags) {
- content = content.toLowerCase();
- }
-
- return content;
}
});
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 1f22e1f1799..c6b5c718d82 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -1811,4 +1811,3 @@ tags:
default: false
force_lowercase_tags:
default: true
- client: true
diff --git a/test/javascripts/components/mini-tag-chooser-test.js.es6 b/test/javascripts/components/mini-tag-chooser-test.js.es6
index 194f9591ae9..d08379be6c1 100644
--- a/test/javascripts/components/mini-tag-chooser-test.js.es6
+++ b/test/javascripts/components/mini-tag-chooser-test.js.es6
@@ -12,7 +12,6 @@ componentTest("default", {
beforeEach() {
this.siteSettings.max_tag_length = 24;
- this.siteSettings.force_lowercase_tags = true;
this.site.set("can_create_tag", true);
this.set("tags", ["jeff", "neil", "arpit"]);
@@ -86,11 +85,11 @@ componentTest("default", {
);
await this.get("subject").expand();
- await this.get("subject").fillInFilter("invalid' Tag");
+ await this.get("subject").fillInFilter("invalid'tag");
await this.get("subject").keyboard("enter");
assert.deepEqual(
this.get("tags"),
- ["jeff", "neil", "arpit", "régis", "joffrey", "invalid-tag"],
+ ["jeff", "neil", "arpit", "régis", "joffrey", "invalidtag"],
"it strips invalid characters in tag"
);
@@ -99,7 +98,7 @@ componentTest("default", {
await this.get("subject").keyboard("enter");
assert.deepEqual(
this.get("tags"),
- ["jeff", "neil", "arpit", "régis", "joffrey", "invalid-tag"],
+ ["jeff", "neil", "arpit", "régis", "joffrey", "invalidtag"],
"it does not allow creating long tags"
);