diff --git a/app/assets/javascripts/discourse/components/markdown.js b/app/assets/javascripts/discourse/components/markdown.js index dc1001d7941..afa9f27a6a9 100644 --- a/app/assets/javascripts/discourse/components/markdown.js +++ b/app/assets/javascripts/discourse/components/markdown.js @@ -142,13 +142,13 @@ Discourse.Markdown = { converter.hooks.chain("postConversion", function(text) { if (!text) return ""; - // don't to mention voodoo in pres + // don't do @username mentions inside
blocks text = text.replace(/([\s\S]*@[\s\S]*)<\/pre>/gi, function(wholeMatch, inner) { return "" + (inner.replace(/@/g, '@')) + ""; }); - // Add @mentions of names - text = text.replace(/([\s\t>,:'|";\]])(@[A-Za-z0-9_-|\.]*[A-Za-z0-9_-|]+)(?=[\s\t<\!:|;',"\?\.])/g, function(x, pre, name) { + // add @username mentions, if valid; must be bounded on left and right by non-word characters + text = text.replace(/(\W)(@[A-Za-z0-9][A-Za-z0-9_]{2,14})(?=\W)/g, function(x, pre, name) { if (mentionLookup(name.substr(1))) { return pre + "" + name + ""; } else {