Skip to content

Commit

Permalink
markdown: Fix client usermention regular expression.
Browse files Browse the repository at this point in the history
Fixes zulip#993.
  • Loading branch information
TigorC authored and timabbott committed Nov 7, 2016
1 parent 44767c5 commit 07d0539
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions frontend_tests/node_tests/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,16 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver
assert.equal(message.flags.length, 2);
assert(message.flags.indexOf('read') !== -1);
assert(message.flags.indexOf('mentioned') !== -1);

input = "test @all";
message = {subject: "No links here", content: echo.apply_markdown(input), raw_content: input};
echo._add_message_flags(message);
assert.equal(message.flags.length, 2);
assert(message.flags.indexOf('mentioned') !== -1);

input = "test @any";
message = {subject: "No links here", content: echo.apply_markdown(input), raw_content: input};
echo._add_message_flags(message);
assert.equal(message.flags.length, 1);
assert(message.flags.indexOf('mentioned') === -1);
}());
4 changes: 2 additions & 2 deletions static/third/marked/lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ inline.breaks = merge({}, inline.gfm, {
inline.zulip = merge({}, inline.breaks, {
emoji: /^:([A-Za-z0-9_\-\+]+?):/,
unicodeemoji: /^(\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff])/,
usermention: /^(@\*\*([^\*]+)?\*\*)/m,
usermention: /^(@(?:\*\*([^\*]+)?\*\*|(\w+)?))/m, // Match multi-word string between @** ** or match any one-word
avatar: /^!avatar\(([^)]+)\)/,
gravatar: /^!gravatar\(([^)]+)\)/,
realm_filters: [],
Expand Down Expand Up @@ -721,7 +721,7 @@ InlineLexer.prototype.output = function(src) {
// usermention (zulip)
if (cap = this.rules.usermention.exec(src)) {
src = src.substring(cap[0].length);
out += this.usermention(cap[2], cap[1]);
out += this.usermention(cap[2] || cap[3], cap[1]);
continue;
}

Expand Down

0 comments on commit 07d0539

Please sign in to comment.