Improve XEP-0245 support.

Namely:
- Only match messages which start with exactly "/me ".
- Simplify the match, checking a string instead of a complex regex.
- Always remove the first four characters in the case of a match, to not
leave an extra leading space.
This commit is contained in:
Emmanuel Gil Peyrot 2018-11-03 12:43:24 +01:00 committed by JC Brand
parent 52aff4f43e
commit 87c77385d8
4 changed files with 9 additions and 11 deletions

5
dist/converse.js vendored
View File

@ -61735,7 +61735,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
if (text && text !== url) {
if (is_me_message) {
text = text.replace(/^\/me/, '');
text = text.substring(4);
}
text = xss__WEBPACK_IMPORTED_MODULE_9___default.a.filterXSS(text, {
@ -61833,8 +61833,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
return false;
}
const match = text.match(/^\/(.*?)(?: (.*))?$/);
return match && match[1] === 'me';
return text.startsWith('/me ');
},
processMessageText() {

View File

@ -144,7 +144,7 @@ converse.plugins.add('converse-message-view', {
const msg_content = msg.querySelector('.chat-msg__text');
if (text && text !== url) {
if (is_me_message) {
text = text.replace(/^\/me/, '');
text = text.substring(4);
}
text = xss.filterXSS(text, {'whiteList': {}});
msg_content.innerHTML = _.flow(
@ -239,8 +239,7 @@ converse.plugins.add('converse-message-view', {
if (!text) {
return false;
}
const match = text.match(/^\/(.*?)(?: (.*))?$/);
return match && match[1] === 'me';
return text.startsWith('/me ');
},
processMessageText () {