Skip to content

Commit

Permalink
fix: do not restrict ID refs to non-colon names
Browse files Browse the repository at this point in the history
In HTML, `id` attributes can be any non-empty string. This change allows
ID-referencing attributes to point to all conforming IDs, by not limiting
their type to `xsd:NCName`.

Fix #783
  • Loading branch information
rdeltour committed Feb 25, 2019
1 parent 8d3c77e commit 365e6e6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ common.attrs.other =
# }

common.data.idref =
datatype.IDREF
datatype.html5.token

common.data.idrefs =
datatype.IDREFS
datatype.html5.space.separated.tokens

common.data.name =
datatype.ID #FIXME
datatype.html5.token

common.data.hash-name =
datatype.html5.name.reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ index 4f18cfee..d208352e 100644

common.data.idref =
- w:IDREF
+ datatype.IDREF
+ datatype.html5.token

common.data.idrefs =
- w:IDREFS
+ datatype.IDREFS
+ datatype.html5.space.separated.tokens

common.data.name =
- w:ID #FIXME
+ datatype.ID #FIXME
+ datatype.html5.token

common.data.hash-name =
- w:hash-name
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1337,4 +1337,21 @@ public void testEntitiesUnknown()
testValidateDocument("xhtml/invalid/entities-unknown.xhtml", "application/xhtml+xml", EPUBVersion.VERSION_3);
}

@Test
public void testIdRefNotNCName()
{
// tests that ID-referencing attributes can refer to non-NCName IDs
testValidateDocument("xhtml/valid/id-ref-not-ncname.xhtml", "application/xhtml+xml",
EPUBVersion.VERSION_3);
}

@Test
public void testIdRefNotFound()
{
// tests that ID-referencing attributes refer to existing IDs
Collections.addAll(expectedErrors, MessageId.RSC_005);
testValidateDocument("xhtml/invalid/id-ref-not-found.xhtml", "application/xhtml+xml",
EPUBVersion.VERSION_3);
}

}
13 changes: 13 additions & 0 deletions src/test/resources/30/single/xhtml/invalid/id-ref-not-found.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Test</title>
<meta charset="UTF-8" />
</head>
<body>
<h1>Test</h1>
<section aria-labelledby="unknown">
<span id="label">label</span>
</section>
</body>
</html>
13 changes: 13 additions & 0 deletions src/test/resources/30/single/xhtml/valid/id-ref-not-ncname.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Test</title>
<meta charset="UTF-8" />
</head>
<body>
<h1>Test</h1>
<section aria-labelledby="1label">
<span id="1label">label</span>
</section>
</body>
</html>

0 comments on commit 365e6e6

Please sign in to comment.