Skip to content

Commit c407546

Browse files
committed
issue #4 - use official regular expression to validate name
see http://php.net/manual/en/language.variables.basics.php
1 parent 9bb1a7d commit c407546

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Element/AbstractElement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public function getName()
5151
*/
5252
public static function nameIsValid($name, $allowBackslash = false)
5353
{
54-
$pattern = '/^[a-zA-Z_][a-zA-Z0-9_]*$/D';
54+
$pattern = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/';
5555
if ($allowBackslash === true) {
56-
$pattern = '/^[a-zA-Z_\\\][a-zA-Z0-9_\\\]*$/D';
56+
$pattern = '/[a-zA-Z_\x7f-\xff\\\][a-zA-Z0-9_\x7f-\xff\\\]*/';
5757
}
58-
return preg_match($pattern, $name) === 1;
58+
return preg_match($pattern, $name);
5959
}
6060
/**
6161
* @param mixed $string

0 commit comments

Comments
 (0)