php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76528 PCRE2 issues a warning about invalid ranges
Submitted: 2018-06-25 19:48 UTC Modified: 2018-06-26 01:48 UTC
From: mail at jens-hausdorf dot de Assigned:
Status: Duplicate Package: PCRE related
PHP Version: 7.3.0alpha2 OS: Windows 10 Home
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 - 4 = ?
Subscribe to this entry?

 
 [2018-06-25 19:48 UTC] mail at jens-hausdorf dot de
Description:
------------
It's working fine in 7.2 however.

Test script:
---------------
<?php
preg_match('/^[\\w-\\.]+$/', 'admin.general.canViewPrivateUserOptions')
?>

Expected result:
----------------
no php warning

Actual result:
--------------
PHP Warning:  preg_match(): Compilation failed: invalid range in character class at offset 4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-25 20:12 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2018-06-25 20:12 UTC] danack@php.net
Can you check - that looks like the error message is right, and the pattern probably isn't what you want.

As you have it in your script, it means "any character that is between any word character to a dot", which doesn't make sense.

If the pattern was instead "[\w\.]" that would mean any word character or a dot.....which is possibly what you meant?

Testing at: https://3v4l.org/66NDo

preg_match('/^[\w\.]+$/', 'admin.general.canViewPrivateUserOptions', $matches);
var_dump($matches);

preg_match('/^[\w-\.]+$/', 'admin.general.canViewPrivateUserOptions', $matches);
var_dump($matches);

preg_match('/^[\\w-\\.]+$/', 'admin.general.canViewPrivateUserOptions', $matches);
var_dump($matches);
 [2018-06-26 01:48 UTC] requinix@php.net
-Status: Feedback +Status: Duplicate
 [2018-06-26 01:48 UTC] requinix@php.net
See bug #76188
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 14:01:31 2024 UTC