Skip to content

Node.js based forum software built for the modern web

closes #1565

barisusaklidbf07f786d63
diff --git a/public/src/modules/composer/tags.js b/public/src/modules/composer/tags.js
index 4f6a6294f4..e5b1a34b83 100644
--- a/public/src/modules/composer/tags.js
+++ b/public/src/modules/composer/tags.js
@@ -13,7 +13,8 @@ define(function() {
}
tagEl.tagsinput({
- maxTags: config.tagsPerTopic
+ maxTags: config.tagsPerTopic,
+ confirmKeys: [13, 188]
});
addTags(postData.tags, tagEl);
diff --git a/src/topics/tags.js b/src/topics/tags.js
index 492723f750..63e67eddd4 100644
--- a/src/topics/tags.js
+++ b/src/topics/tags.js
@@ -11,9 +11,13 @@ module.exports = function(Topics) {
Topics.createTags = function(tags, tid, timestamp, callback) {
if(Array.isArray(tags)) {
tags = tags.slice(0, meta.config.tagsPerTopic || 5);
+
async.each(tags, function(tag, next) {
- tag = utils.removePunctuation(tag.trim().toLowerCase()).substr(0, meta.config.maximumTagLength || 15);
+ tag = cleanUpTag(tag);
+ if (tag.length < (meta.config.minimumTagLength || 3)) {
+ return next();
+ }
db.setAdd('topic:' + tid + ':tags', tag);
db.sortedSetAdd('tag:' + tag + ':topics', timestamp, tid, function(err) {
@@ -26,6 +30,17 @@ module.exports = function(Topics) {
}
};
+ function cleanUpTag(tag) {
+ tag = tag.trim().toLowerCase();
+ var matches = tag.match(/^-*(.+?)-*$/);
+ if (matches && matches.length > 1) {
+ tag = matches[1];
+ }
+ tag = tag.replace(/[\.,\/#!$%\^&\*;:{}=_`<>'"~()?\|]/g, '');
+ tag = tag.substr(0, meta.config.maximumTagLength || 15);
+ return tag;
+ }
+
function updateTagCount(tag) {
Topics.getTagTopicCount(tag, function(err, count) {
if (!err) {