Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: stop appending a stray '<' to unterminated block-text elements#313

Open
spokodev wants to merge 1 commit into
taoqf:mainfrom
spokodev:fix/unterminated-block-text-stray-lt
Open

fix: stop appending a stray '<' to unterminated block-text elements#313
spokodev wants to merge 1 commit into
taoqf:mainfrom
spokodev:fix/unterminated-block-text-stray-lt

Conversation

@spokodev

@spokodev spokodev commented Jul 8, 2026

Copy link
Copy Markdown

An unterminated raw-text element (script/style/pre) with no closing tag keeps a stray < in its text:

parse('<script>var a = 1;', { script: true }) // text 'var a = 1;<'  (expected 'var a = 1;')
parse('<style>.a{color:red}')                 // text '.a{color:red}<'

dataEndPos was 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.

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;<'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant