beatonma / django-wm

Automatic Webmention functionality for Django models
https://beatonma.org/webmentions_tester/
GNU General Public License v3.0
12 stars 2 forks source link

HCards only being found if they're the first item in the soup #33

Closed philgyford closed 1 year ago

philgyford commented 2 years ago

The HCard.from_soup() method tries to loop through all of the items that mf2py has found in the page source:

        for item in parsed_data.get("items", []):
            try:
                return _parse_hcard(item, save)
            except NotEnoughData as e:
                log.debug(e)
                continue

But this currently results in it giving up after the first item, if that wasn't an h-card that generated a NotEnoughData exception.

e.g. if there are two items found, an h-entry and then an h-card, _parse_hcard() will return None when it looks at the h-entry, and so from_soup() will immediately do the same, before it can send the h-card to _parse_hcard().