Skip to content

Commit

Permalink
functions.inc.php: escape minus in regex
Browse files Browse the repository at this point in the history
This makes CGP work on PHP 7.3 as it otherwise only shows an "Unknown
host" error message and logs the following PHP warning:

PHP Warning:  preg_match(): Compilation failed: invalid range in
character class at offset 4 in .../inc/functions.inc.php on line 37
  • Loading branch information
julianbrost committed Dec 9, 2018
1 parent 1920ca2 commit 16e710f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion inc/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function GET($index = NULL, $value = NULL) {
case 'h': # host
case 'pi': # plugin instance
case 'ti': # type instance
if (!preg_match('/^[\w-.: ]+$/u', $value)) {
if (!preg_match('/^[\w\-.: ]+$/u', $value)) {
error_log(sprintf('Invalid %s in $_GET["%s"]: "%s"', $desc[$index], $index, $value));
return NULL;
}
Expand Down

1 comment on commit 16e710f

@BubonicPestilence
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, error prone version will be: [\w.: -]
Due to "dash not treated as 'range' if it's supplied as last symbol inside symbol set"

Please sign in to comment.