Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gumbo: update adjusted foreign attributes #2842

Merged
merged 3 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# [submodule "test/html5lib-tests"]
# path = test/html5lib-tests
# url = https://github.com/html5lib/html5lib-tests.git
# branch = master
[submodule "test/html5lib-tests"]
path = test/html5lib-tests
url = https://github.com/html5lib/html5lib-tests.git
branch = master
url = https://github.com/flavorjones/html5lib-tests.git
branch = flavorjones-fix-template-2023-04
27 changes: 13 additions & 14 deletions gumbo-parser/src/foreign_attrs.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ANSI-C code produced by gperf version 3.1 */
/* Command-line: gperf -m100 -n src/foreign_attrs.gperf */
/* Computed positions: -k'2,8' */
/* Computed positions: -k'8-9' */
/* Filtered by: gperf-filter.sed */

#include "replacement.h"
Expand Down Expand Up @@ -29,9 +29,9 @@ hash (register const char *str, register size_t len)
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 2,
11, 10, 11, 9, 7, 6, 11, 11, 1, 0,
11, 5, 11, 11, 4, 11, 11, 11, 11, 11,
11, 3, 11, 11, 11, 11, 11, 11, 11, 11,
11, 1, 11, 10, 4, 4, 11, 11, 3, 11,
11, 5, 3, 11, 0, 11, 2, 11, 11, 11,
11, 2, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
Expand All @@ -51,15 +51,14 @@ hash (register const char *str, register size_t len)
switch (len)
{
default:
hval += asso_values[(unsigned char)str[8]];
/*FALLTHROUGH*/
case 8:
hval += asso_values[(unsigned char)str[7]];
/*FALLTHROUGH*/
case 7:
case 6:
case 5:
case 4:
case 3:
case 2:
hval += asso_values[(unsigned char)str[1]];
break;
}
return hval;
Expand All @@ -70,21 +69,21 @@ gumbo_get_foreign_attr_replacement (register const char *str, register size_t le
{
static const unsigned char lengthtable[] =
{
5, 11, 9, 13, 10, 10, 10, 11, 10, 8, 8
5, 10, 13, 9, 13, 10, 11, 11, 10, 10, 8
};
static const ForeignAttrReplacement wordlist[] =
{
{"xmlns", "xmlns", GUMBO_ATTR_NAMESPACE_XMLNS},
{"xmlns:xlink", "xlink", GUMBO_ATTR_NAMESPACE_XMLNS},
{"xlink:href", "href", GUMBO_ATTR_NAMESPACE_XLINK},
{"xlink:arcrole", "arcrole", GUMBO_ATTR_NAMESPACE_XLINK},
{"xml:space", "space", GUMBO_ATTR_NAMESPACE_XML},
{"xlink:actuate", "actuate", GUMBO_ATTR_NAMESPACE_XLINK},
{"xlink:type", "type", GUMBO_ATTR_NAMESPACE_XLINK},
{"xlink:href", "href", GUMBO_ATTR_NAMESPACE_XLINK},
{"xlink:role", "role", GUMBO_ATTR_NAMESPACE_XLINK},
{"xlink:title", "title", GUMBO_ATTR_NAMESPACE_XLINK},
{"xmlns:xlink", "xlink", GUMBO_ATTR_NAMESPACE_XMLNS},
{"xlink:role", "role", GUMBO_ATTR_NAMESPACE_XLINK},
{"xlink:show", "show", GUMBO_ATTR_NAMESPACE_XLINK},
{"xml:lang", "lang", GUMBO_ATTR_NAMESPACE_XML},
{"xml:base", "base", GUMBO_ATTR_NAMESPACE_XML}
{"xml:lang", "lang", GUMBO_ATTR_NAMESPACE_XML}
};

if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
Expand Down
2 changes: 1 addition & 1 deletion gumbo-parser/src/foreign_attrs.gperf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ ForeignAttrReplacement;

%%
"xlink:actuate", "actuate", GUMBO_ATTR_NAMESPACE_XLINK
"xlink:arcrole", "arcrole", GUMBO_ATTR_NAMESPACE_XLINK
"xlink:href", "href", GUMBO_ATTR_NAMESPACE_XLINK
"xlink:role", "role", GUMBO_ATTR_NAMESPACE_XLINK
"xlink:show", "show", GUMBO_ATTR_NAMESPACE_XLINK
"xlink:title", "title", GUMBO_ATTR_NAMESPACE_XLINK
"xlink:type", "type", GUMBO_ATTR_NAMESPACE_XLINK
"xml:base", "base", GUMBO_ATTR_NAMESPACE_XML
"xml:lang", "lang", GUMBO_ATTR_NAMESPACE_XML
"xml:space", "space", GUMBO_ATTR_NAMESPACE_XML
"xmlns", "xmlns", GUMBO_ATTR_NAMESPACE_XMLNS
Expand Down
9 changes: 7 additions & 2 deletions test/html5/test_tree_construction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def compare_nodes(node, ng_node)
else
attributes[attr[:name]].value
end
assert_equal(attr[:value], value)
assert_equal(attr[:value], value, "expected #{attr}[:value] to equal #{value.inspect}")
end
assert_equal(
node[:children].length,
Expand Down Expand Up @@ -117,7 +117,12 @@ def run_test
end

# Test the errors.
assert_equal(@test[:errors].length, doc.errors.length, "Wrong number of errors for #{@test[:data]}")
errpayload = doc.errors.map(&:to_s).join("\n")
assert_equal(
@test[:errors].length,
doc.errors.length,
"Expected #{@test[:errors].length} errors for #{@test[:data]}, found:\n#{errpayload}",
)

# The new, standardized tokenizer errors live in @test[:new_errors]. Let's
# match each one to exactly one error in doc.errors. Unfortunately, the
Expand Down