Skip to content

elements with invalid class names beginning with "h-" are parsed as mf with empty type #127

@sknebel

Description

@sknebel

http://microformats.org/wiki/microformats-2-parsing says:

The "*" for root (and property) class names consists only of lowercase a-z and '-' characters.

when php-mf2 discovers a class beginning with h- that is not a valid name according to this specification, it still parses the element as if it were a microformat root, but does set "type": [], which I assume will crash quite a few consuming applications that expect type[0] to always exist.

I initially discovered it with this typo:

<div class="h-entry>">
<a href="https://example.com" class="u-url">content</a></div>

which parses as

{
    "items": [
        {
            "type": [],
            "properties": {
                "name": ["content" ],
                "url": [ "https://example.com"]
            }
        }
    ],

Other examples include class="h-👍", class="h-hentry_" or class="h-"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions