Skip to content

Reject trailing newlines in CounterExample method-name validation#22

Merged
rasuvaeff merged 1 commit into
masterfrom
fix/pcre-anchor-z
Jul 25, 2026
Merged

Reject trailing newlines in CounterExample method-name validation#22
rasuvaeff merged 1 commit into
masterfrom
fix/pcre-anchor-z

Conversation

@rasuvaeff

Copy link
Copy Markdown
Owner

PCRE \$ without /D matches before a trailing \n. Four regexes anchored with \$:

File Pattern role Tier
CounterExample::toExamplesCode() examples-method name passed to reflection/replay path 1
Internal\PropertyInterceptor (PROPERTY_RUNS) env value → int cast 2
Internal\PropertyInterceptor (PROPERTY_SEED) env value → int cast 2
Internal\SeedStorage trim()'ed seed-file content → int cast 2

Fix: anchor all four with \\z. All patterns are in private methods/consts (bc-check stays green).

Regression coverage: CounterExampleTest::rejectsExamplesMethodNameWithTrailingNewline. The Tier-2 patterns are hygiene-only — env values and trim()'ed file contents already strip the trailing \n before the regex runs, so the change is not observable through public API.

Verification: composer build green (646 tests, 270408 assertions).

Release: 2.7.1 — Reject trailing newlines in CounterExample method-name validation.

PCRE $ matches before a trailing \n. Switch the examples-method-name
regex in CounterExample to \z so "<name>\n" is rejected instead of
reaching the reflection/replay path. Hygiene: also anchor the two
integer regexes in PropertyInterceptor (PROPERTY_RUNS / PROPERTY_SEED
env parsers) and SeedStorage (seed-file reader) — env values and
trim()'ed seed-file contents already strip the newline before the
regex, so those changes are not observable through public API.
@rasuvaeff
rasuvaeff merged commit fca795f into master Jul 25, 2026
7 checks passed
@rasuvaeff
rasuvaeff deleted the fix/pcre-anchor-z branch July 25, 2026 15:07
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