-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Adding a pattern property to a schema is supposed to validate a value using the provided regular expression. This is done in generated code using StringPatternConstraint:
class StringPatternConstraint {
public static function check(string $input, string $pattern, string $pointer): void {
$match = \preg_match("/".$pattern."/", $input);
/* ... */However, this fails if $pattern contains a forward slash, because that collides with the / delimiter used here. A workaround is to use a double backslash when defining pattern in the schema so that it becomes \/ in the call to preg_match (this does change the meaning of the schema for other validators).
I thought that this was a case where we simply needed to use preg_quote, however that escapes all special characters in $pattern, not just the delimiter.
Metadata
Metadata
Assignees
Labels
No labels