Skip to content

Commit

Permalink
Allow lowercase ASCII in HTML declaration (spec 0.30)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinst committed Jun 29, 2021
1 parent 4861cfd commit 4ca7a59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public class HtmlInlineParser implements InlineContentParser {
.c('"').c('\'').c('=').c('<').c('>').c('`')
.build();

private static final AsciiMatcher declaration = AsciiMatcher.builder().range('A', 'Z').build();

@Override
public ParsedInline tryParse(InlineParserState inlineParserState) {
Scanner scanner = inlineParserState.scanner();
Expand Down Expand Up @@ -58,7 +56,7 @@ public ParsedInline tryParse(InlineParserState inlineParserState) {
if (tryCdata(scanner)) {
return htmlInline(start, scanner);
}
} else if (declaration.matches(c)) {
} else if (asciiLetter.matches(c)) {
if (tryDeclaration(scanner)) {
return htmlInline(start, scanner);
}
Expand Down Expand Up @@ -187,9 +185,9 @@ private static boolean tryCdata(Scanner scanner) {
}

private static boolean tryDeclaration(Scanner scanner) {
// spec: A declaration consists of the string <!, a name consisting of one or more uppercase ASCII letters,
// whitespace, a string of characters not including the character >, and the character >.
scanner.match(declaration);
// spec: A declaration consists of the string <!, an ASCII letter, zero or more characters not including
// the character >, and the character >.
scanner.match(asciiLetter);
if (scanner.whitespace() <= 0) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ public void declaration() {
assertRendering("inline <!FOO>", "<p>inline &lt;!FOO&gt;</p>\n");
assertRendering("inline <!FOO >", "<p>inline <!FOO ></p>\n");
assertRendering("inline <!FOO 'bar'>", "<p>inline <!FOO 'bar'></p>\n");

// Lowercase
assertRendering("inline <!foo bar>", "<p>inline <!foo bar></p>\n");
}
}

0 comments on commit 4ca7a59

Please sign in to comment.