Skip to content
Snippets Groups Projects
Commit 624af7ed authored by HJ's avatar HJ :fire:
Browse files

Merge branch 'harden-parser' into 'develop'

fix regex misinterpreting tag name in badly formed HTML

See merge request !1835
parents ae5181d2 0109724a
No related branches found
No related tags found
2 merge requests!1861Update master branch,!1835fix regex misinterpreting tag name in badly formed HTML
Pipeline #45050 passed
fix regex issue in HTML parser/renderer
......@@ -149,7 +149,9 @@ export default {
// Handle tag nodes
if (Array.isArray(item)) {
const [opener, children, closer] = item
const Tag = getTagName(opener)
let Tag = getTagName(opener)
if (Tag.toLowerCase() === 'script') Tag = 'js-exploit'
if (Tag.toLowerCase() === 'style') Tag = 'css-exploit'
const fullAttrs = getAttrs(opener, () => true)
const attrs = getAttrs(opener)
const previouslyMentions = currentMentions !== null
......
......@@ -5,7 +5,7 @@
* @return {String} - tagname, i.e. "div"
*/
export const getTagName = (tag) => {
const result = /(?:<\/(\w+)>|<(\w+)\s?.*?\/?>)/gi.exec(tag)
const result = /(?:<\/(\w+)>|<(\w+)\s?.*?\/?>)/gis.exec(tag)
return result && (result[1] || result[2])
}
......
  • HJ :fire: @hj

    mentioned in commit 4bc7873e

    ·

    mentioned in commit 4bc7873e

    Toggle commit list
  • HJ :fire: @hj

    mentioned in commit 321a131c

    ·

    mentioned in commit 321a131c

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment