Skip to content

Commit 282a63e

Browse files
eraydbighappyface
authored andcommitted
Fix relative-path case where first segment contains a colon (#360)
1 parent 337855d commit 282a63e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/JsonSchema/Constraints/FormatConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function check(&$element, $schema = null, JsonPointer $path = null, $i =
9090
$validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
9191
} elseif (strlen($element)) { // relative-path reference
9292
$pathParts = explode('/', $element, 2);
93-
if ($pathParts[0][0] !== '.' && strpos($pathParts[0], ':') !== false) {
93+
if (strpos($pathParts[0], ':') !== false) {
9494
$validURL = null;
9595
} else {
9696
$validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);

tests/Constraints/FormatTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ public function getValidFormats()
126126
array('http://bluebox.org', 'uri'),
127127
array('//bluebox.org', 'uri'),
128128
array('/absolutePathReference/', 'uri'),
129+
array('./relativePathReference/', 'uri'),
130+
array('./relative:PathReference/', 'uri'),
129131
array('relativePathReference/', 'uri'),
132+
array('relative/Path:Reference/', 'uri'),
130133

131134
array('[email protected]', 'email'),
132135

@@ -176,6 +179,7 @@ public function getInvalidFormats()
176179
array('1 123 4424', 'phone'),
177180

178181
array('htt:/bluebox.org', 'uri'),
182+
array('.relative:path/reference/', 'uri'),
179183
array('', 'uri'),
180184

181185
array('info@somewhere', 'email'),

0 commit comments

Comments
 (0)