Bug #77388 [Com]: invalid range in character class doesn't bubble up
| From: | sjon at hortensius dot net | Date: | Sun, 06 Jan 2019 10:22:21 +0000 |
| Subject: | Bug #77388 [Com]: invalid range in character class doesn't bubble up | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218811@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77388&edit=1
ID: 77388
Comment by: sjon at hortensius dot net
Reported by: sjon at hortensius dot net
Summary: invalid range in character class doesn't bubble up
Status: Open
Type: Bug
Package: PCRE related
Operating System: archlinux
PHP Version: 7.3.0
Block user comment: N
Private report: N
New Comment:
this has been fixed in https://vcs.pcre.org/pcre2?view=revision&revision=1058
It's also advisable to stop passing the BAD_ESCAPE_IS_LITERAL flag by default from PHP, should
I file a separate bug/feature for that?
Previous Comments:
------------------------------------------------------------------------
[2019-01-01 14:58:25] sjon at hortensius dot net
thanks, I agree. I've filed https://bugs.exim.org/show_bug.cgi?id=2362
upstream
------------------------------------------------------------------------
[2018-12-31 11:41:01] nikic@php.net
Just checked, /[^_-\s]/bad_escape_is_literal in pcre2test works, so this is indeed the reason.
I think this is a PCRE bug though, because I don't think that option should affect this
particular case, because \s is a legal escape, it's just not allowed as part of a range.
Something like /[^\s-_]/bad_escape_is_literal results in a "Unrecognized escape sequence
"\s"" error.
------------------------------------------------------------------------
[2018-12-31 11:35:25] nikic@php.net
Might be because we're setting PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL for BC reasons, though I
don't think it's *supposed* to affect this case.
------------------------------------------------------------------------
[2018-12-31 11:22:46] sjon at hortensius dot net
Description:
------------
I found this while going through https://3v4l.org/bughunt/7.3.0/7.2.13+7.2.12
I'm not sure if this is a PHP or a PCRE bug (or maybe not a bug at all) but running the same
regexp through pcre2test yields an error - but php accepts it since 7.3
$ pcre2test
PCRE2 version 10.32 2018-09-10
re> /[^_-\s]/
Failed: error 150 at offset 6: invalid range in character class
Test script:
---------------
See https://3v4l.org/KICjT
var_dump(preg_replace( '/[^_-\s]/' , '' , 'a b c d _ x' ));
Expected result:
----------------
Warning: preg_replace(): Compilation failed: invalid range in character class at offset 5 in
/in/KICjT on line 3
Actual result:
--------------
string(5) "abcd_"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77388&edit=1