Skip to content

fix: prevent statement regex from matching whitespace-only lines - #31

Merged
TekWizely merged 1 commit into
mainfrom
fix/statement-block-start-traiing-spaces
Aug 7, 2026
Merged

fix: prevent statement regex from matching whitespace-only lines#31
TekWizely merged 1 commit into
mainfrom
fix/statement-block-start-traiing-spaces

Conversation

@TekWizely

@TekWizely TekWizely commented Aug 7, 2026

Copy link
Copy Markdown
Owner

A line consisting of only a statement delimiter followed by two or more spaces (e.g., % ) was being incorrectly parsed as a statement line instead of a statement block start. This occurred because the regex engine backtracked into the greedy [[:blank:]]+ quantifier to satisfy the (.+) requirement of the statement body.

Updated STATEMENT_REGEX to require at least one non-blank character after the delimiter and space prefix ([^[:blank:]].*). Also added corresponding test cases to the regex test suite to prevent future regressions.

Fixes #29


cc: @atsag

A line consisting of only a statement delimiter followed by two or more spaces
(e.g., `%  `) was being incorrectly parsed as a statement line instead of a
statement block start. This occurred because the regex engine backtracked into the
greedy `[[:blank:]]+` quantifier to satisfy the `(.+)` requirement of the
statement body.

Updated `STATEMENT_REGEX` to require at least one non-blank character after the
delimiter and space prefix (`[^[:blank:]].*`). Also added corresponding test cases
to the regex test suite to prevent future regressions.
@TekWizely
TekWizely merged commit 6c44d85 into main Aug 7, 2026
5 checks passed
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.

Blank spaces following the % delimiter (e.g preceding an if statement) cause unexpected interpretation

1 participant