sabre-io / uri

:earth_asia: Functions for making sense out of URIs in PHP

Home Page:http://sabre.io/uri/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unknown modifier error on the regex for uris that have an authority part

mlambley opened this issue · comments

Sorry to hassle you again folks, but I'm running the tests on the project and am coming up against an issue with functions.php line 360.

Numerous tests are failing with the same issue, but I'm focusing on the "http://example.org:8080/" test.

I've pasted the relevant code into http://sandbox.onlinephpfunctions.com/ so that I can test it against different PHP versions. The code is:

<?php
$uri = '//example.org:8080/';
$regex = '
          %^
            //
            (?: (?<user> [^:@]+) (: (?<pass> [^@]+)) @)?
            (?<host> ( [^:/]* | \[ [^\]]+ \] ))
            (?: : (?<port> [0-9]+))?
            (?<path> / .*)?
          $%x
        ';
var_dump(preg_match($regex, $uri, $matches));
var_dump($matches);

The error I'm getting is:

<b>Warning</b>:  preg_match(): Unknown modifier '
' in <b>[...][...]</b> on line <b>12</b><br />
bool(false)
NULL

Any advice would be appreciated. Thank you.

Looks like this is another duplicate of #25
Peter's fix (removing the newlines from the beginning and end of the regex) seems to have fixed it.
Once that is merged this can be closed.