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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail at jens-hausdorf dot de
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Thu Dec 12 14:01:28 2024 UTC