Skip to content

Commit f83914c

Browse files
authored
Merge pull request #2 from fossar/fix/srcset-value
Fix srcset handling
2 parents f7a324a + b7eba15 commit f83914c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

htmLawed.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,10 @@ function hl_tag($t){
519519
$v = str_replace("­", ' ', (strpos($v, '&') !== false ? str_replace(array('­', '­', '­'), ' ', $v) : $v)); # double-quoted char: soft-hyphen; appears here as "­" or hyphen or something else depending on viewing software
520520
if($k == 'srcset'){
521521
$v2 = '';
522-
foreach(explode(',', $v) as $k1=>$v1){
522+
$pattern = "/(?:[^\"'\s]+\s*(?:\d+[wx])+)/";
523+
preg_match_all($pattern, $v, $matches);
524+
$matches = call_user_func_array('array_merge', $matches);
525+
foreach($matches as $k1=>$v1){
523526
$v1 = explode(' ', ltrim($v1), 2);
524527
$k1 = isset($v1[1]) ? trim($v1[1]) : '';
525528
$v1 = trim($v1[0]);

0 commit comments

Comments
 (0)