Bugfix: whitelist fails when empty or when using : #938

This commit is contained in:
the-djmaze 2023-02-09 16:16:50 +01:00
parent 6c14055006
commit b2079f7263

View file

@ -402,19 +402,19 @@ export class MessageModel extends AbstractModel {
regex = SettingsUserStore.viewImagesWhitelist() regex = SettingsUserStore.viewImagesWhitelist()
.trim() .trim()
.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&') .replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')
.replace(/[\s\r\n,;:]+/g, '|') .replace(/[\s\r\n,;]+/g, '|')
.replace(/\|+/g, '|'); .replace(/\|+/g, '|');
if (regex) { if (regex) {
console.log('whitelist images = '+regex); console.log('whitelist images = '+regex);
regex = new RegExp(regex); regex = new RegExp(regex);
if (this.from[0]?.email.match(regex)) { if (this.from[0]?.email.match(regex)) {
regex = 0; regex = null;
} }
} }
} }
let hasImages = false, let hasImages = false,
isValid = src => { isValid = src => {
if (!regex || src.match(regex)) { if (null == regex || (regex && src.match(regex))) {
return true; return true;
} }
hasImages = true; hasImages = true;