Skip to content

Commit

Permalink
Meta: Ensure rel attribute exists before querying its value
Browse files Browse the repository at this point in the history
Previously, the WPT importer would fail to import files with link tags
that didn't have a `rel` attribute.
  • Loading branch information
tcl3 committed Dec 23, 2024
1 parent 673537b commit 5c03258
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Meta/import-wpt-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def handle_starttag(self, tag, attrs):
self._resources.append(attr_dict["src"])
if tag == "link":
attr_dict = dict(attrs)
if attr_dict["rel"] == "stylesheet":
if "rel" in attr_dict and attr_dict["rel"] == "stylesheet":
self._resources.append(attr_dict["href"])

def handle_endtag(self, tag):
Expand Down Expand Up @@ -100,7 +100,7 @@ def __init__(self, url):
def handle_starttag(self, tag, attrs):
if tag == "link":
attr_dict = dict(attrs)
if attr_dict["rel"] == "match" or attr_dict["rel"] == "mismatch":
if "rel" in attr_dict and (attr_dict["rel"] == "match" or attr_dict["rel"] == "mismatch"):
if self.ref_test_link_found:
raise RuntimeError("Ref tests with multiple match or mismatch links are not currently supported")
self.test_type = TestType.REF
Expand Down

0 comments on commit 5c03258

Please sign in to comment.