Skip to content

Commit 7dbf81a

Browse files
committed
Fix due to #40 (comment)
1 parent 1b7a21a commit 7dbf81a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/PropertyProcessor/Property/StringProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function addPatternValidator(PropertyInterface $property, JsonSchema $
5858
return;
5959
}
6060

61-
$escapedPattern = addcslashes(str_replace('\\\\', '\\\\\\\\', $json[static::JSON_FIELD_PATTERN]), '/');
61+
$escapedPattern = addcslashes($json[static::JSON_FIELD_PATTERN], '/');
6262

6363
if (@preg_match("/$escapedPattern/", '') === false) {
6464
throw new SchemaException(

tests/Objects/StringPropertyTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ public function testPatternMatchingStringIsValid(
189189
string $pattern,
190190
?string $propertyValue
191191
): void {
192-
$className = $this->generateClassFromFileTemplate('StringPropertyPattern.json', [$pattern], $configuration, false);
192+
$className = $this->generateClassFromFileTemplate(
193+
'StringPropertyPattern.json',
194+
[$pattern],
195+
$configuration,
196+
false
197+
);
193198

194199
$object = new $className(['property' => $propertyValue]);
195200
$this->assertSame($propertyValue, $object->getProperty());
@@ -216,7 +221,7 @@ public function validPatternProvider(): array
216221
'[0-9]{4}-[0-9]{2}-[0-9]{2}',
217222
'Contains a Date 2018-12-12 and something else'
218223
],
219-
'Regex escape test' => ['^\\\\\\\\/\'$', '\\\\/\''],
224+
'Regex escape test' => ['^\\\\\\\\/\'$', '\\/\''],
220225
]
221226
);
222227
}

0 commit comments

Comments
 (0)