Skip to content

Commit

Permalink
EWPP-4071: Do not escape the url when generating it in the FileValueO…
Browse files Browse the repository at this point in the history
…bject.
  • Loading branch information
imanoleguskiza authored and upchuk committed May 23, 2024
1 parent da52b0a commit 0e58450
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ValueObject/FileValueObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/src/Unit/ValueObject/FileValueObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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&param2=b';
$file = FileValueObject::fromArray($data);
$this->assertEquals('http://example.com/test.pdf?param1=a&param2=b', $file->getUrl());
}

}

0 comments on commit 0e58450

Please sign in to comment.