Commit 8ae1a4d
fix(core): close-tag regex misses script/style end tags with attrs/whitespace
CodeQL js/bad-tag-filter (HIGH) on PR #241: the literal `<\/script>` /
`<\/style>` patterns in stripTags() left bodies behind for HTML5-tolerated
end-tag forms like `</script >` (trailing space) and `</script foo="bar">`
(end-tag attributes, silently ignored by browsers per spec). A crafted
source HTML could leak script/style body text into the visible-word
vocabulary used for parity coverage scoring.
Fix: mirror the opening-tag pattern's `\b[^>]*` on the close tag too.
The `\b` after the tag name prevents over-matching `</scripts>` while
the `[^>]*` consumes any tolerated end-tag content up to the closing `>`.
Regression test covers all 4 previously-vulnerable forms:
- `</script >` (trailing whitespace)
- `</script foo="bar">` (end-tag attrs)
- `</style >` (style branch)
- `</SCRIPT>` (case)
Asserts none of 4 leaked tokens appear in the parity report when the
decomposition correctly omits the script/style content.
Signed-off-by: homen <hshum2018@gmail.com>1 parent 517d74c commit 8ae1a4d
2 files changed
Lines changed: 58 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
157 | 207 | | |
158 | 208 | | |
159 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
130 | 136 | | |
131 | | - | |
132 | | - | |
| 137 | + | |
| 138 | + | |
133 | 139 | | |
134 | 140 | | |
135 | 141 | | |
| |||
0 commit comments