mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Have COLOR_REGEX constant
This commit is contained in:
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
Block a user