This commit is contained in:
Ludeeus 2020-08-06 08:25:50 +00:00
parent 04df530fdd
commit db8a5feff6

View File

@ -16,7 +16,7 @@ function hasHtml(data) {
return /<[a-z][\s\S]*>/i.test(data); return /<[a-z][\s\S]*>/i.test(data);
} }
function hasUnquotedHTags(data) { function hasUnquotedTags(data) {
// Guard against unquoted HTML tags https://github.com/formatjs/formatjs/issues/1878 // Guard against unquoted HTML tags https://github.com/formatjs/formatjs/issues/1878
return /[^'](<.*>)[^']/i.test(data); return /[^'](<.*>)[^']/i.test(data);
} }
@ -28,7 +28,7 @@ function recursiveCheckHasHtml(file, data, errors, recKey) {
recursiveCheckHasHtml(file, data[key], errors, nextRecKey); recursiveCheckHasHtml(file, data[key], errors, nextRecKey);
} else if (hasHtml(data[key])) { } else if (hasHtml(data[key])) {
errors.push(`HTML found in ${file.path} at key ${recKey}.${key}`); errors.push(`HTML found in ${file.path} at key ${recKey}.${key}`);
} else if (hasUnquotedHTags(data[key])) { } else if (hasUnquotedTags(data[key])) {
errors.push( errors.push(
`Unquoted tags found in ${file.path} at key ${recKey}.${key}` `Unquoted tags found in ${file.path} at key ${recKey}.${key}`
); );