Skip to content

Commit

Permalink
bug #54080 [Routing] Enhance error handling in StaticPrefixCollection…
Browse files Browse the repository at this point in the history
… for compatibility with libpcre2-10.43 (Lustmored)

This PR was merged into the 5.4 branch.

Discussion
----------

[Routing] Enhance error handling in StaticPrefixCollection for compatibility with libpcre2-10.43

The error handling function in the StaticPrefixCollection class has been extended. A new check for 'Compilation failed: length of lookbehind assertion is not limited' message error was added to improve the error capture process.

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #54067
| License       | MIT

Recent changes in libpcre2 have changed the error message we are trying to catch in StaticPrefixCollection. The change comes from this commit (please take a look at changes in `src/pcre2_error.c`):

PCRE2Project/pcre2@1e78b77

This PR checks for both possible error messages for backwards-compatible way of handling errors.

I did not add any tests as current tests are throwing PHP warnings when run with newer libpcre2, which are gone after the proposed change and I'm unsure how to proceed with that fact.

Commits
-------

7183330 Enhance error handling in StaticPrefixCollection for compatibility with libpcre2-10.43
  • Loading branch information
derrabus committed Feb 27, 2024
2 parents 6a229c7 + 7183330 commit dc1da9c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ private function getCommonPrefix(string $prefix, string $anotherPrefix): array

public static function handleError(int $type, string $msg)
{
return str_contains($msg, 'Compilation failed: lookbehind assertion is not fixed length');
return str_contains($msg, 'Compilation failed: lookbehind assertion is not fixed length')
|| str_contains($msg, 'Compilation failed: length of lookbehind assertion is not limited');
}
}

0 comments on commit dc1da9c

Please sign in to comment.