Skip to content

Attribute values are extracted incorrectly when they are not enclosed in quotation marks. #2

Closed

Description

@ktarasov

When using the check_links utility, a problem was discovered. If attributes within an HTML document are not enclosed in quotes (and this is permissible in some cases, for example, when the value does not contain spaces or special characters and many minifiers do this), the attribute value is extracted incorrectly.

How to reproduce

Test HTML document:

<!DOCTYPE html>
<html lang=en>
<head>
	<meta charset=UTF-8>
	<meta name=viewport content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<a href=books/learning-zig/chapter11/ class=link>Chapter 11</a>
</body>
</html>

If you load this document using the zigquery library and then try to retrieve the a tag, for example like this:

    var doc = try zq.Document.initFromSlice(allocator, html);
    defer doc.deinit();

    // Extract all <A>
    const sel_a = try doc.find("a");
    var it_a = sel_a.iterator();
    while (it_a.next()) |el_a| {
        const attr_href = el_a.attr("href");
        if (attr_href) |href| {
            std.debug.print("{s}\n", .{ href });
        }
    }

It will print “books” instead of the expected “books/learning-zig/chapter11/”.

Activity

  1. self-assigned this
    on Aug 30, 2026
  2. OrlovEvgeny commented on Aug 31, 2026

    @OrlovEvgeny
    Owner

    Hi, thanks for report

    fixed in #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions