microformats/php-mf2

wrongly implied photo

sknebel opened this issue · 1 comments

Given

<span class="h-card">
  <a href="http://example.com">
    <img src="https://example.com">
  </a> 
  <span class="p-name"><a href="/User:Example.com">Max Mustermann</a></span>
</span>

php-mf2 resolves the <img src="" as an implied photo, but there is no rule allowing so: Per http://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties, rules for implied photo from img src:

if img.h-x[src], then use src for photo

Clearly doesn't apply, img is not root

else if .h-x>img[src]:only-of-type:not[.h-*] then use that img src for photo

imgis not a direct child of root

else if .h-x>:only-child:not[.h-*]>img[src]:only-of-type:not[.h-*], then use that img’s src for photo

parent of img is not the only child of root

(discovered via indieweb.org/chat-names page, where default avatars where parsed as photo)

The problem seems to be that our rule matching .h-x>:only-child:not[.h-*]>img[src]:only-of-type:not[.h-*] doesn’t actually test the :only-child part and only the :not[.h-*] part.

'./*[not(contains(concat(" ", @class), " h-"))]/img[count(preceding-sibling::img)+count(following-sibling::img)=0]',