Skip to content

Commit a495fbe

Browse files
Merge pull request SimpleMachines#8838 from jdarwood007/2.1/fix8820
[2.1] Fix quotes in names for mention handling
2 parents 864fcaa + cde4abc commit a495fbe

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Sources/Mentions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ protected static function getPossibleMentions($body)
305305
$count = count($match);
306306

307307
for ($i = 1; $i <= $count; $i++)
308-
$names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i))));
308+
$names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i))), ENT_QUOTES);
309309
}
310310

311311
$names = array_unique($names);

Themes/default/scripts/mentions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ var atwhoConfig = {
4343
callback(callbackArray);
4444
}
4545
});
46+
},
47+
tplEval: function (tpl, map, caller) {
48+
var error, error1, template;
49+
template = tpl;
50+
try {
51+
if (typeof tpl !== 'string') {
52+
template = tpl(map);
53+
}
54+
// When SCEditor is disabled, inserted names may contain some HTML if it was escaped.
55+
if (caller == 'onInsert') {
56+
map['name'] = map['name'].toString().replace("&#034;", '"').replace('&#39;', "'");
57+
}
58+
return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
59+
return map[key];
60+
});
61+
} catch (error1) {
62+
error = error1;
63+
return "";
64+
}
4665
}
4766
}
4867
};

0 commit comments

Comments
 (0)