Skip to content

Commit

Permalink
Fix overzealous HTML validator
Browse files Browse the repository at this point in the history
I forgot h1-h6 could have numbers in them...
  • Loading branch information
Zarel committed May 16, 2020
1 parent b0f0cb2 commit 88365ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,13 +1051,13 @@ export class CommandContext extends MessageContext {
const tags = htmlContent.match(/<\/?[^<>]*/g);
if (tags) {
const ILLEGAL_TAGS = [
'script', 'head', 'body', 'html', 'canvas', 'base', 'meta', 'link', '!doctype',
'script', 'head', 'body', 'html', 'canvas', 'base', 'meta', 'link',
];
const LEGAL_AUTOCLOSE_TAGS = [
// no-close tags
// void elements (no-close tags)
'br', 'area', 'embed', 'hr', 'img', 'source', 'track', 'input', 'wbr', 'col',
// autoclose tags
'li', 'p',
'p', 'li', 'dt', 'dd', 'option', 'tr', 'th', 'td', 'thead', 'tbody', 'tfoot', 'colgroup',
// PS custom element
'psicon',
];
Expand All @@ -1081,7 +1081,7 @@ export class CommandContext extends MessageContext {
continue;
}

if (ILLEGAL_TAGS.includes(tagName) || !/^[a-z]+$/.test(tagName)) {
if (ILLEGAL_TAGS.includes(tagName) || !/^[a-z]+[0-9]?$/.test(tagName)) {
this.errorReply(`Illegal tag <${tagName}> can't be used here.`);
return null;
}
Expand Down

0 comments on commit 88365ab

Please sign in to comment.