Thanks @mvandemar for the report and screenshots.
48261.diff is a first iteration, just to help the discussion further.
This patch adds the extra condition preg_match( '#(?:^\s*|\s+)rel\s*=#', $link_html )
if the attributes-regex are matched. Here (?:)
is a non-capturing group and we check if rel is the first attribute (that can be without white space from left in $link_html
) or the second (or later) attribute (that need a white space from left in $link_html
). I first tried to modify the existing attributes-regex with this approach but it ended up with more changes, so I currently prefer this approach.
ps: we could simplify to preg_match( '#(^\s*|\s+)rel\s*=#', $link_html )
as the first version was when I tested it within the attributes-regex, with existing capturing groups.