fix: stop appending a stray '<' to unterminated block-text elements - #313
fix: stop appending a stray '<' to unterminated block-text elements#313spokodev wants to merge 1 commit into
Conversation
When a block-text element (script, style, pre, ...) has no closing tag, the text-end position fell back to dataEndPos, which subtracted the length of the *opening* frame-flag wrapper (frameflag.length + 2) rather than the *closing* one (frameflag.length + 3). The resulting off-by-one included the leading '<' of the internal </documentfragmentcontainer> sentinel, so parsing '<script>var a = 1;' produced text 'var a = 1;<'.
taoqf
left a comment
There was a problem hiding this comment.
-
unterminated block-text elements
does not append a stray "<" to an unclosed <script>:AssertionError: expected 'var a = 1;<' to equal 'var a = 1;'
- expected - actual
-var a = 1;<
+var a = 1;at Assertion.fail (test/node_modules/should/cjs/should.js:275:17)
at Assertion.value (test/node_modules/should/cjs/should.js:356:19)
at Context. (test/tests/incomplete-blocktext.js:8:22)
at process.processImmediate (node:internal/timers:504:21) -
unterminated block-text elements
does not append a stray "<" to an unclosed <style>:AssertionError: expected '.a{color:red}<' to equal '.a{color:red}'
- expected - actual
-.a{color:red}<
+.a{color:red}at Assertion.fail (test/node_modules/should/cjs/should.js:275:17)
at Assertion.value (test/node_modules/should/cjs/should.js:356:19)
at Context. (test/tests/incomplete-blocktext.js:14:21)
at process.processImmediate (node:internal/timers:504:21)
|
This passes once |
An unterminated raw-text element (
script/style/pre) with no closing tag keeps a stray<in its text:dataEndPoswas computed from the opening wrapper length, but the closing sentinel is one character longer, so the<of the sentinel was included when the element has no closing tag. Off by one in the EOF branch.