-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preg_split(): Compilation failed: escape sequence is invalid #92
Comments
Hi @erlangsec -- Could you give more details on where that may be happening, or even more helpful would be a test case? Currently it seems all tests are passing in 7.3 for version 1.1.5... but maybe I'm missing a test somewhere. I had a quick look around at the generated patterns as well but couldn't find any hyphens. |
Thanks for asking, the bug is triggered by any Received header, as far as I can tell, including the one from your original tests:
Apparently, this header is also treated with some special parsing patterns (which makes sense). |
I've found that the character The error is resolved by switching from PHP7.3 to PHP7.2. Or by removing/replacing the character. |
While I do not have any official source for this theory, it looks like since Proposed fix in pull request #93. |
Excellent, thanks for that @erlangsec I'll review your change and aim to release a fix this weekend... can't for the life of me think of why I grouped \A like that, so will have a look around. Can you tell me if, without that fix, a unit test is failing for you and which one, and if your fix fixes it for you as well? It seems Travis on PHP 7.3 isn't erroring out, and I'm wondering if you may know why: https://travis-ci.org/zbateson/mail-mime-parser/jobs/573601308 Thanks again! |
Without proposed fix: There were 24 errors:
and so on ... But with fix, no errors: My environment: |
Rewrite regex to fix PHP7.3 bug in preg_split() #92
Released in 1.1.6. Thanks for your help on this one! |
I get the error message above, which looks like a regex compliation bug related to PHP 7.3, originating from:
/vendor/zbateson/mail-mime-parser/src/Header/Consumer/AbstractConsumer.php:187
According to this resource, e.g. "the hyphen now needs to be escaped" (if this could be a relevant case).
See also PHP 7.3 migration guide for PCRE:
https://wiki.php.net/rfc/pcre2-migration#backward_incompatible_changes
The text was updated successfully, but these errors were encountered: