From 0e5845007cbec338197d032e7f7447befd7fb212 Mon Sep 17 00:00:00 2001 From: Imanol Eguskiza Date: Fri, 12 Apr 2024 15:50:48 +0200 Subject: [PATCH] EWPP-4071: Do not escape the url when generating it in the FileValueObject. --- src/ValueObject/FileValueObject.php | 2 +- tests/src/Unit/ValueObject/FileValueObjectTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ValueObject/FileValueObject.php b/src/ValueObject/FileValueObject.php index e04553745..71be0a019 100644 --- a/src/ValueObject/FileValueObject.php +++ b/src/ValueObject/FileValueObject.php @@ -157,7 +157,7 @@ public static function fromFileLink(FileLinkItem $link): ValueObjectInterface { * Property value. */ public function getUrl(): string { - return UrlHelper::filterBadProtocol($this->url); + return UrlHelper::stripDangerousProtocols($this->url); } /** diff --git a/tests/src/Unit/ValueObject/FileValueObjectTest.php b/tests/src/Unit/ValueObject/FileValueObjectTest.php index 7c0e2d330..2b2b79402 100644 --- a/tests/src/Unit/ValueObject/FileValueObjectTest.php +++ b/tests/src/Unit/ValueObject/FileValueObjectTest.php @@ -40,6 +40,11 @@ public function testFromArray() { $data['language_code'] = 'fr'; $file = FileValueObject::fromArray($data); $this->assertEquals('fr', $file->getLanguageCode()); + + // Assert that urls are not escaped when returned by the object. + $data['url'] ='http://example.com/test.pdf?param1=a¶m2=b'; + $file = FileValueObject::fromArray($data); + $this->assertEquals('http://example.com/test.pdf?param1=a¶m2=b', $file->getUrl()); } }