Skip to content

Commit

Permalink
fix: Attributes id injection in first tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
srackham committed Feb 12, 2018
1 parent 6b175e8 commit 862a463
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rimu/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export namespace BlockAttributes {
}
if (id) {
id = id.toLowerCase()
let has_id = /id=".*?"/i.test(tag)
let has_id = /^<[^<]*id=".*?"/i.test(tag)
if (has_id || ids.indexOf(id) > -1) {
Options.errorCallback(`duplicate 'id' attribute: ${id}`)
}
Expand Down
9 changes: 9 additions & 0 deletions test/rimu-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,15 @@
"reset": true
}
},
{
"description": "html id injection in first tag",
"input": ".#foo\n<p></p><p id=\"bar\"></p>",
"expectedOutput": "<p id=\"foo\"></p><p id=\"bar\"></p>",
"expectedCallback": "",
"options": {
"reset": true
}
},
{
"description": "html attributes skipped by safeMode=2",
"input": ".[style=\"color: red;\"]\nError message",
Expand Down

0 comments on commit 862a463

Please sign in to comment.