Skip to content

Commit 5c8fe7a

Browse files
Stop reporting HTML4-specific parse errors
1 parent 1ae6c63 commit 5c8fe7a

File tree

12 files changed

+100
-688
lines changed

12 files changed

+100
-688
lines changed

gwt-src/nu/validator/htmlparser/gwt/BrowserTreeBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2007 Henri Sivonen
3-
* Copyright (c) 2008-2009 Mozilla Foundation
3+
* Copyright (c) 2008-2017 Mozilla Foundation
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a
66
* copy of this software and associated documentation files (the "Software"),
@@ -376,7 +376,7 @@ JavaScriptObject getDocumentFragment() {
376376
}
377377

378378
protected void documentMode(DocumentMode mode, String publicIdentifier,
379-
String systemIdentifier, boolean html4SpecificAdditionalErrorChecks)
379+
String systemIdentifier)
380380
throws SAXException {
381381
// document.setUserData("nu.validator.document-mode", mode, null);
382382
}

src/nu/validator/htmlparser/common/DoctypeExpectation.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/nu/validator/htmlparser/common/DocumentModeHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2007 Henri Sivonen
3+
* Copyright (c) 2017 Mozilla Foundation
34
*
45
* Permission is hereby granted, free of charge, to any person obtaining a
56
* copy of this software and associated documentation files (the "Software"),
@@ -39,8 +40,7 @@ public interface DocumentModeHandler {
3940
* @param mode the document mode
4041
* @param publicIdentifier the public id of the doctype or <code>null</code> if unavailable
4142
* @param systemIdentifier the system id of the doctype or <code>null</code> if unavailable
42-
* @param html4SpecificAdditionalErrorChecks <code>true</code> if HTML 4-specific checks were enabled, <code>false</code> otherwise
4343
* @throws SAXException if things go wrong
4444
*/
45-
public void documentMode(DocumentMode mode, String publicIdentifier, String systemIdentifier, boolean html4SpecificAdditionalErrorChecks) throws SAXException;
45+
public void documentMode(DocumentMode mode, String publicIdentifier, String systemIdentifier) throws SAXException;
4646
}

src/nu/validator/htmlparser/dom/DOMTreeBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2007 Henri Sivonen
3-
* Copyright (c) 2008-2010 Mozilla Foundation
3+
* Copyright (c) 2008-2017 Mozilla Foundation
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a
66
* copy of this software and associated documentation files (the "Software"),
@@ -251,7 +251,7 @@ protected DOMTreeBuilder(DOMImplementation implementation) {
251251
* java.lang.String, java.lang.String, boolean)
252252
*/
253253
protected void documentMode(DocumentMode mode, String publicIdentifier,
254-
String systemIdentifier, boolean html4SpecificAdditionalErrorChecks)
254+
String systemIdentifier)
255255
throws SAXException {
256256
document.setUserData("nu.validator.document-mode", mode, null);
257257
}

src/nu/validator/htmlparser/dom/HtmlDocumentBuilder.java

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2007 Henri Sivonen
3-
* Copyright (c) 2007-2008 Mozilla Foundation
3+
* Copyright (c) 2007-2017 Mozilla Foundation
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a
66
* copy of this software and associated documentation files (the "Software"),
@@ -34,7 +34,6 @@
3434
import javax.xml.parsers.ParserConfigurationException;
3535

3636
import nu.validator.htmlparser.common.CharacterHandler;
37-
import nu.validator.htmlparser.common.DoctypeExpectation;
3837
import nu.validator.htmlparser.common.DocumentModeHandler;
3938
import nu.validator.htmlparser.common.Heuristics;
4039
import nu.validator.htmlparser.common.TokenHandler;
@@ -122,8 +121,6 @@ private static DOMImplementation jaxpDOMImplementation() {
122121

123122
private DocumentModeHandler documentModeHandler = null;
124123

125-
private DoctypeExpectation doctypeExpectation = DoctypeExpectation.HTML;
126-
127124
private boolean checkingNormalization = false;
128125

129126
private boolean scriptingEnabled = false;
@@ -140,8 +137,6 @@ private static DOMImplementation jaxpDOMImplementation() {
140137

141138
private XmlViolationPolicy streamabilityViolationPolicy = XmlViolationPolicy.ALLOW;
142139

143-
private boolean html4ModeCompatibleWithXhtml1Schemata = false;
144-
145140
private boolean mappingLangToXmlLang = false;
146141

147142
private XmlViolationPolicy xmlnsPolicy = XmlViolationPolicy.FATAL;
@@ -223,14 +218,12 @@ private void lazyInit() {
223218
this.driver.setCommentPolicy(commentPolicy);
224219
this.driver.setContentNonXmlCharPolicy(contentNonXmlCharPolicy);
225220
this.driver.setContentSpacePolicy(contentSpacePolicy);
226-
this.driver.setHtml4ModeCompatibleWithXhtml1Schemata(html4ModeCompatibleWithXhtml1Schemata);
227221
this.driver.setMappingLangToXmlLang(mappingLangToXmlLang);
228222
this.driver.setXmlnsPolicy(xmlnsPolicy);
229223
this.driver.setHeuristics(heuristics);
230224
for (CharacterHandler characterHandler : characterHandlers) {
231225
this.driver.addCharacterHandler(characterHandler);
232226
}
233-
this.treeBuilder.setDoctypeExpectation(doctypeExpectation);
234227
this.treeBuilder.setDocumentModeHandler(documentModeHandler);
235228
this.treeBuilder.setScriptingEnabled(scriptingEnabled);
236229
this.treeBuilder.setReportingDoctype(reportingDoctype);
@@ -457,29 +450,6 @@ public void setScriptingEnabled(boolean scriptingEnabled) {
457450
}
458451
}
459452

460-
/**
461-
* Returns the doctype expectation.
462-
*
463-
* @return the doctypeExpectation
464-
*/
465-
public DoctypeExpectation getDoctypeExpectation() {
466-
return doctypeExpectation;
467-
}
468-
469-
/**
470-
* Sets the doctype expectation.
471-
*
472-
* @param doctypeExpectation
473-
* the doctypeExpectation to set
474-
* @see nu.validator.htmlparser.impl.TreeBuilder#setDoctypeExpectation(nu.validator.htmlparser.common.DoctypeExpectation)
475-
*/
476-
public void setDoctypeExpectation(DoctypeExpectation doctypeExpectation) {
477-
this.doctypeExpectation = doctypeExpectation;
478-
if (treeBuilder != null) {
479-
treeBuilder.setDoctypeExpectation(doctypeExpectation);
480-
}
481-
}
482-
483453
/**
484454
* Returns the document mode handler.
485455
*
@@ -521,19 +491,6 @@ public void setStreamabilityViolationPolicy(
521491
driver = null;
522492
}
523493

524-
/**
525-
* Whether the HTML 4 mode reports boolean attributes in a way that repeats
526-
* the name in the value.
527-
* @param html4ModeCompatibleWithXhtml1Schemata
528-
*/
529-
public void setHtml4ModeCompatibleWithXhtml1Schemata(
530-
boolean html4ModeCompatibleWithXhtml1Schemata) {
531-
this.html4ModeCompatibleWithXhtml1Schemata = html4ModeCompatibleWithXhtml1Schemata;
532-
if (driver != null) {
533-
driver.setHtml4ModeCompatibleWithXhtml1Schemata(html4ModeCompatibleWithXhtml1Schemata);
534-
}
535-
}
536-
537494
/**
538495
* Returns the <code>Locator</code> during parse.
539496
* @return the <code>Locator</code>
@@ -542,16 +499,6 @@ public Locator getDocumentLocator() {
542499
return driver.getDocumentLocator();
543500
}
544501

545-
/**
546-
* Whether the HTML 4 mode reports boolean attributes in a way that repeats
547-
* the name in the value.
548-
*
549-
* @return the html4ModeCompatibleWithXhtml1Schemata
550-
*/
551-
public boolean isHtml4ModeCompatibleWithXhtml1Schemata() {
552-
return html4ModeCompatibleWithXhtml1Schemata;
553-
}
554-
555502
/**
556503
* Whether <code>lang</code> is mapped to <code>xml:lang</code>.
557504
* @param mappingLangToXmlLang

src/nu/validator/htmlparser/impl/ErrorReportingTokenizer.java

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -369,28 +369,10 @@ private boolean isAstralPrivateUse(int c) {
369369
}
370370

371371
@Override protected void errWarnLtSlashInRcdata() throws SAXException {
372-
if (html4) {
373-
err((stateSave == Tokenizer.DATA ? "CDATA" : "RCDATA")
374-
+ " element \u201C"
375-
+ endTagExpectation
376-
+ "\u201D contained the string \u201C</\u201D, but it was not the start of the end tag. (HTML4-only error)");
377-
} else {
378-
warn((stateSave == Tokenizer.DATA ? "CDATA" : "RCDATA")
379-
+ " element \u201C"
380-
+ endTagExpectation
381-
+ "\u201D contained the string \u201C</\u201D, but this did not close the element.");
382-
}
383-
}
384-
385-
@Override protected void errHtml4LtSlashInRcdata(char folded)
386-
throws SAXException {
387-
if (html4 && (index > 0 || (folded >= 'a' && folded <= 'z'))
388-
&& ElementName.IFRAME != endTagExpectation) {
389-
err((stateSave == Tokenizer.DATA ? "CDATA" : "RCDATA")
390-
+ " element \u201C"
391-
+ endTagExpectation.getName()
392-
+ "\u201D contained the string \u201C</\u201D, but it was not the start of the end tag. (HTML4-only error)");
393-
}
372+
warn((stateSave == Tokenizer.DATA ? "CDATA" : "RCDATA")
373+
+ " element \u201C"
374+
+ endTagExpectation
375+
+ "\u201D contained the string \u201C</\u201D, but this did not close the element.");
394376
}
395377

396378
@Override protected void errCharRefLacksSemicolon() throws SAXException {
@@ -448,26 +430,10 @@ private boolean isAstralPrivateUse(int c) {
448430
err("A slash was not immediately followed by \u201C>\u201D.");
449431
}
450432

451-
@Override protected void errHtml4XmlVoidSyntax() throws SAXException {
452-
if (html4) {
453-
err("The \u201C/>\u201D syntax on void elements is not allowed. (This is an HTML4-only error.)");
454-
}
455-
}
456-
457433
@Override protected void errNoSpaceBetweenAttributes() throws SAXException {
458434
err("No space between attributes.");
459435
}
460436

461-
@Override protected void errHtml4NonNameInUnquotedAttribute(char c)
462-
throws SAXException {
463-
if (html4
464-
&& !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
465-
|| (c >= '0' && c <= '9') || c == '.' || c == '-'
466-
|| c == '_' || c == ':')) {
467-
err("Non-name character in an unquoted attribute value. (This is an HTML4-only error.)");
468-
}
469-
}
470-
471437
@Override protected void errLtOrEqualsOrGraveInUnquotedAttributeOrNull(
472438
char c) throws SAXException {
473439
switch (c) {

0 commit comments

Comments
 (0)