File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
lib/internal/Magento/Framework/Url Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ class ValidatorTest extends TestCase
23
23
/** @var string[] */
24
24
protected $ expectedValidationMessages = [Uri::INVALID => "Invalid URL '%value%'. " ];
25
25
26
+ /** @var string[] */
27
+ protected $ invalidURL = [Uri::INVALID => "Invalid URL 'php://filter'. " ];
28
+
26
29
protected function setUp (): void
27
30
{
28
31
$ objectManager = new ObjectManager ($ this );
@@ -59,4 +62,13 @@ public function testIsValidWhenInvalid()
59
62
$ this ->assertFalse ($ this ->object ->isValid ('%value% ' ));
60
63
$ this ->assertEquals ($ this ->expectedValidationMessages , $ this ->object ->getMessages ());
61
64
}
65
+
66
+ public function testIsValidWhenInvalidURL ()
67
+ {
68
+ $ this ->laminasValidator
69
+ ->method ('isValid ' )
70
+ ->with ('php://filter ' );
71
+ $ this ->assertFalse ($ this ->object ->isValid ('php://filter ' ));
72
+ $ this ->assertEquals ($ this ->invalidURL , $ this ->object ->getMessages ());
73
+ }
62
74
}
Original file line number Diff line number Diff line change @@ -55,11 +55,14 @@ public function isValid($value)
55
55
$ this ->setValue ($ value );
56
56
57
57
$ valid = $ this ->validator ->isValid ($ value );
58
-
59
- if (!$ valid ) {
60
- $ this ->error (Uri::INVALID );
58
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
59
+ $ protocol = parse_url ($ value ? $ value : '' , PHP_URL_SCHEME );
60
+ if ($ valid && ($ protocol === 'https ' || $ protocol === 'http ' )) {
61
+ return true ;
61
62
}
62
63
63
- return $ valid ;
64
+ $ this ->error (Uri::INVALID );
65
+
66
+ return false ;
64
67
}
65
68
}
You can’t perform that action at this time.
0 commit comments