Skip to content

fix: bound unclosed comment source positions to input - #48

Merged
ai merged 1 commit into
postcss:mainfrom
feritcemkahraman:fix/unclosed-comment-source
Oct 8, 2026
Merged

ai merged 1 commit into
postcss:mainfrom
feritcemkahraman:fix/unclosed-comment-source

Conversation

@feritcemkahraman

Copy link
Copy Markdown
Contributor

Parsing an unfinished comment such as /*a puts its source end offset at 4 even though the original input has only 3 characters. The root end is also beyond EOF. This happens because the fault-tolerant tokenizer can advance past the input and Input.fromOffset() returns a location even for that offset.

Clamp the comment end to the last original character and the root end to EOF. Preserve the usual convention: comment line/column identify its last character, while the offset is exclusive. Add a multiline unfinished-comment regression covering both source ranges and extraction of the original comment text.

Validation: the new regression fails before the fix; all 49 unit tests pass after it. npm run test:lint and npm run test:integration pass (33 real-world resources).

@ai
ai merged commit 1728651 into postcss:main Oct 8, 2026
5 checks passed
@ai

ai commented Oct 8, 2026

Copy link
Copy Markdown
Member

Thanks

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.

2 participants