Skip to content

Commit

Permalink
Dollar assertion fails trailing newline
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Jan 2, 2025
1 parent d9af364 commit 6b5e9ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Regex/private.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function _denoted(string $message, string $pattern, int $offset): string {

function _pcre_pattern(string $pattern, ?string $modifiers): string {
$delimiter = \str_contains($pattern, '/') ? "\1" : '/';
return $delimiter . $pattern . $delimiter . $modifiers;
return $delimiter . $pattern . $delimiter . "D$modifiers";
}

function _unprefixed(string $string, string $prefix): string {
Expand Down
5 changes: 5 additions & 0 deletions test/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ public function afterRegexCall_phpState_isNotPolluted(): void {
}
$this->assertNull(\error_get_last());
}

#[Test]
public function dollarAssertion_failsTrailingNewline(): void {
$this->assertFalse(re_test('foo$', "foo\n"));
}
}

0 comments on commit 6b5e9ff

Please sign in to comment.