Skip to content

Off-by-one in extractHtmlAttr can miss attributes at end of tag #10

Description

@calin-marian

Problem

extractHtmlAttr in formatter.zig uses pos + attr_name.len < tag_inner.len as the loop bound. This is off by one — if an attribute name starts at the last valid position, the loop terminates before checking it. For example, a tag like <a href="url"> where href ends exactly at the boundary would fail to match.

Additionally, whitespace checks use manual character comparisons (!= ' ' and != '\t' and != '\n') instead of the standard library's std.ascii.isWhitespace, missing characters like \r.

Fix

  • Changed loop bound to <=
  • Replaced manual whitespace checks with std.ascii.isWhitespace

References

Fixed in PR #7 (commit 1e12dd1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions