Skip to content

Commit bf93767

Browse files
Merge branch 'AC-8425' into cia-2.4.7-beta2-develop-bugfix-07112023
2 parents 500a42a + 511ade5 commit bf93767

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

lib/internal/Magento/Framework/Url/Test/Unit/ValidatorTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ValidatorTest extends TestCase
2323
/** @var string[] */
2424
protected $expectedValidationMessages = [Uri::INVALID => "Invalid URL '%value%'."];
2525

26+
/** @var string[] */
27+
protected $invalidURL = [Uri::INVALID => "Invalid URL 'php://filter'."];
28+
2629
protected function setUp(): void
2730
{
2831
$objectManager = new ObjectManager($this);
@@ -59,4 +62,13 @@ public function testIsValidWhenInvalid()
5962
$this->assertFalse($this->object->isValid('%value%'));
6063
$this->assertEquals($this->expectedValidationMessages, $this->object->getMessages());
6164
}
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+
}
6274
}

lib/internal/Magento/Framework/Url/Validator.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@ public function isValid($value)
5555
$this->setValue($value);
5656

5757
$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;
6162
}
6263

63-
return $valid;
64+
$this->error(Uri::INVALID);
65+
66+
return false;
6467
}
6568
}

0 commit comments

Comments
 (0)