mirror of https://github.com/vector-im/riot-web
Have COLOR_REGEX constant
parent
b951713f7f
commit
0f8ab99158
|
@ -28,11 +28,7 @@ emojione.imagePathSVG = 'emojione/svg/';
|
||||||
emojione.imageType = 'svg';
|
emojione.imageType = 'svg';
|
||||||
|
|
||||||
const EMOJI_REGEX = new RegExp(emojione.unicodeRegexp+"+", "gi");
|
const EMOJI_REGEX = new RegExp(emojione.unicodeRegexp+"+", "gi");
|
||||||
const COLOR_REGEX = /^[#a-z0-9]+$/;
|
const COLOR_REGEX = /#[0-9a-fA-F]{6}/;
|
||||||
const ALLOWED_CSS = {
|
|
||||||
"background-color": COLOR_REGEX,
|
|
||||||
"color": COLOR_REGEX,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* modified from https://github.com/Ranks/emojione/blob/master/lib/js/emojione.js
|
/* modified from https://github.com/Ranks/emojione/blob/master/lib/js/emojione.js
|
||||||
* because we want to include emoji shortnames in title text
|
* because we want to include emoji shortnames in title text
|
||||||
|
@ -160,7 +156,7 @@ var sanitizeHtmlParams = {
|
||||||
const customAttributeValue = attribs[customAttributeKey];
|
const customAttributeValue = attribs[customAttributeKey];
|
||||||
if (customAttributeValue &&
|
if (customAttributeValue &&
|
||||||
typeof customAttributeValue === 'string' &&
|
typeof customAttributeValue === 'string' &&
|
||||||
/#[0-9a-fA-F]{6}/.test(customAttributeValue)
|
COLOR_REGEX.test(customAttributeValue)
|
||||||
) {
|
) {
|
||||||
style += cssAttributeKey + ":" + customAttributeValue + ";";
|
style += cssAttributeKey + ":" + customAttributeValue + ";";
|
||||||
delete attribs[customAttributeKey];
|
delete attribs[customAttributeKey];
|
||||||
|
|
Loading…
Reference in New Issue