You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<script>
var str = 'hey <form';
if (!str.match(new RegExp('<(form|iframe)', 'g'))) {
// ...
}
</script>
... an array of 3 content strings is parsed from this script content, but I would expect this to be a single parsed content string, since any tag opening characters are within strings inside the inline script block.
Here is a complete minimal example:
(I'm using htmlnano, but I traced the behaviour to the posthtml-parser dependency of htmlnano)
const htmlnano = require('htmlnano');
return htmlnano
.process(
`<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<script>
var str = 'hey <form';
if (!str.match(new RegExp('<(form|iframe)', 'g'))) {
// ...
}
</script>
</body>
</html>`,
{
custom: [
(tree, options) => {
tree.match({ tag: 'script' }, (node) => {
// node is passed in via the tree parsed by posthtml-parser
console.log(node.content);
// console.log output:
// [ '\n var str = \'hey ',
// '<form\';\n\n if (!str.match(new RegExp(\'',
// '<(form|iframe|meta|frameset|script|link|object|embed)\', \'g\'))) {\n //\n }\n ' ]
// an array of 3 content strings is parsed, but I would
// expect this to be a single parsed content string,
// since any tag opening characters are within strings
// inside the inline script block
return node;
});
return tree;
},
]
},
)
.then((result) => {
// ...
});
Take the following inline style block:
... an array of 3 content strings is parsed from this script content, but I would expect this to be a single parsed content string, since any tag opening characters are within strings inside the inline script block.
Here is a complete minimal example:
(I'm using htmlnano, but I traced the behaviour to the posthtml-parser dependency of htmlnano)
(A similar kind of issue as seen in #18)
The text was updated successfully, but these errors were encountered: