Skip to content

Commit

Permalink
Fix parsing of a style property in "style" attribute when the value c…
Browse files Browse the repository at this point in the history
…ontains a colon
  • Loading branch information
Imangazaliev committed Feb 9, 2021
1 parent e5bcdd3 commit 7fc9cc1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/DiDom/StyleAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function parseStyleAttribute()
$properties = explode(';', $styleString);

foreach ($properties as $property) {
list($name, $value) = explode(':', $property);
list($name, $value) = explode(':', $property, 2);

$name = trim($name);
$value = trim($value);
Expand Down
6 changes: 3 additions & 3 deletions tests/StyleAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public function getPropertyDataProvider()
'16px',
],
[
'color: blue; font-size: 16px; border: 1px solid black;',
'font-size',
'16px',
'background-image: url(https://example.com/image.jpg); background-repeat: no-repeat',
'background-image',
'url(https://example.com/image.jpg)',
],
[
'color: blue; font-size: 16px; border: 1px solid black;',
Expand Down

0 comments on commit 7fc9cc1

Please sign in to comment.