mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 20:23:39 +00:00
Apply changes to markdownLegacy.js
This commit is contained in:
@@ -99,9 +99,15 @@ const sanatizeScriptTags = (content)=>{
|
|||||||
const tagTypes = ['div', 'span', 'a'];
|
const tagTypes = ['div', 'span', 'a'];
|
||||||
const tagRegex = new RegExp(`(${
|
const tagRegex = new RegExp(`(${
|
||||||
_.map(tagTypes, (type)=>{
|
_.map(tagTypes, (type)=>{
|
||||||
return `\\<${type}|\\</${type}>`;
|
return `\\<${type}\\b|\\</${type}>`;
|
||||||
}).join('|')})`, 'g');
|
}).join('|')})`, 'g');
|
||||||
|
|
||||||
|
// Special "void" tags that can be self-closed but don't need to be.
|
||||||
|
const voidTags = new Set([
|
||||||
|
'area', 'base', 'br', 'col', 'command', 'hr', 'img',
|
||||||
|
'input', 'keygen', 'link', 'meta', 'param', 'source'
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
marked : Markdown,
|
marked : Markdown,
|
||||||
@@ -128,6 +134,13 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(match === `</${type}>`){
|
if(match === `</${type}>`){
|
||||||
|
// Closing tag: Check we expect it to be closed.
|
||||||
|
// The accumulator may contain a sequence of voidable opening tags,
|
||||||
|
// over which we skip before checking validity of the close.
|
||||||
|
while (acc.length && voidTags.has(_.last(acc).type) && _.last(acc).type != type) {
|
||||||
|
acc.pop();
|
||||||
|
}
|
||||||
|
// Now check that what remains in the accumulator is valid.
|
||||||
if(!acc.length){
|
if(!acc.length){
|
||||||
errors.push({
|
errors.push({
|
||||||
line : lineNumber,
|
line : lineNumber,
|
||||||
|
|||||||
Reference in New Issue
Block a user