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 f1e3ee4 commit d990464
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/org/rimumarkup/utils.kt
Expand Up @@ -74,7 +74,7 @@ object BlockAttributes {
}
if (id.isNotBlank()) {
id = id.toLowerCase()
val has_id = result.contains(Regex("""id=".*?"""", RegexOption.IGNORE_CASE))
val has_id = result.contains(Regex("""^<[^<]*id=".*?"""", RegexOption.IGNORE_CASE))
if (has_id || ids.contains(id)) {
Options.errorCallback("""duplicate 'id' attribute: ${id}""")
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/test/resources/rimu-tests.json
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 d990464

Please sign in to comment.