microformats / php-mf2

php-mf2 is a pure, generic microformats-2 parser for PHP. It makes HTML as easy to consume as JSON.
Creative Commons Zero v1.0 Universal
193 stars 38 forks source link

Fix invalid property class name parsing #250

Closed gRegorLove closed 8 months ago

gRegorLove commented 1 year ago

The nestedMfPropertyNamesFromClass method was parsing property classes regardless if they were valid (e.g. p-4). Updated the method to use existing mfNamesFromClass method, which uses the correct regex to skip those classes.

Also fixed a test for nestedMfPropertyNamesFromClass which asserted the response array was equal. The expected and actual response array had the same values, but in different order. The order is not important in that response, so I switched the assertion to assertEqualsCanonicalizing.

This also appeared to fix #246, so I added a test to confirm that.

Fixes #249 Fixes #246

gRegorLove commented 1 year ago

Note there's still three "risky" tests that don't perform assertions. I didn't update those in this PR but can in a subsequent one.

sknebel commented 1 year ago

LGTM, matches what I expect, but would like second review from someone deeper in PHP

gRegorLove commented 1 year ago

Added an additional test that @sknebel provided:

<div class=" h-5 pt-2">
    <div class="p-4 h-entry">
        <a class="u-url" href="https://example.com/bar">bar </a>
    </div>
    <div class="p-4 h-entry">
        <a class="u-url" href="https://example.com/foo">foo</a>
    </div>
</div>

Parsed empty on http://php.microformats.io/?id=20231011231942570