Skip to content

Commit

Permalink
Fixed decoding img src attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
parpalak committed Feb 11, 2024
1 parent 275915c commit c4ee100
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/S2/Rose/Extractor/HtmlDom/DomExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ protected static function processDomElement(\DOMNode $domNode, DomState $domStat

case 'img':
$domState->attachImg(
html_entity_decode($domNode->getAttribute('src'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5),
rawurldecode(html_entity_decode($domNode->getAttribute('src'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5)),
$domNode->getAttribute('width'),
$domNode->getAttribute('height'),
html_entity_decode($domNode->getAttribute('alt'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Rose/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function testFeatures(

$img1 = $resultSet11->getItems()[0]->getImageCollection()->offsetGet(1);
$this->assertNotNull($img1);
$this->assertEquals('2.jpg', $img1->getSrc());
$this->assertEquals('2 3.jpg', $img1->getSrc());
$this->assertEquals('20', $img1->getWidth());
$this->assertEquals('25', $img1->getHeight());
$this->assertEquals('Alternative text', $img1->getAlt());
Expand Down Expand Up @@ -424,7 +424,7 @@ public function indexableProvider()
,
(new Indexable('id_1', 'Another instance', 'The same id but another instance. Word "content" is present here. Twice: content. Delimiters must be $...$ or \[...\]', 20))
,
(new Indexable('id_4', 'Another instance', 'Nothing is here but images: <img src="1.jpg" width="10" height="15"> <img src="2.jpg" width="20" height="25" alt="Alternative text" />', 20))
(new Indexable('id_4', 'Another instance', 'Nothing is here but images: <img src="1.jpg" width="10" height="15"> <img src="2%203.jpg" width="20" height="25" alt="Alternative text" />', 20))
,
];

Expand Down

0 comments on commit c4ee100

Please sign in to comment.