зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1650090 - Stop reporting HTML4-specific parse errors. DONTBUILD NPOTB r=alchen
Differential Revision: https://phabricator.services.mozilla.com/D82021
This commit is contained in:
Родитель
48a99da41f
Коммит
c53017c5a8
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2007 Henri Sivonen
|
||||
* Copyright (c) 2007-2015 Mozilla Foundation
|
||||
* Copyright (c) 2007-2017 Mozilla Foundation
|
||||
* Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla
|
||||
* Foundation, and Opera Software ASA.
|
||||
*
|
||||
|
@ -447,11 +447,6 @@ public class Tokenizer implements Locator {
|
|||
*/
|
||||
private boolean wantsComments = false;
|
||||
|
||||
/**
|
||||
* <code>true</code> when HTML4-specific additional errors are requested.
|
||||
*/
|
||||
protected boolean html4;
|
||||
|
||||
/**
|
||||
* Whether the stream is past the first 1024 bytes.
|
||||
*/
|
||||
|
@ -495,8 +490,6 @@ public class Tokenizer implements Locator {
|
|||
|
||||
private XmlViolationPolicy namePolicy = XmlViolationPolicy.ALTER_INFOSET;
|
||||
|
||||
private boolean html4ModeCompatibleWithXhtml1Schemata;
|
||||
|
||||
private int mappingLangToXmlLang;
|
||||
|
||||
// ]NOCPP]
|
||||
|
@ -731,17 +724,6 @@ public class Tokenizer implements Locator {
|
|||
this.namePolicy = namePolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the html4ModeCompatibleWithXhtml1Schemata.
|
||||
*
|
||||
* @param html4ModeCompatibleWithXhtml1Schemata
|
||||
* the html4ModeCompatibleWithXhtml1Schemata to set
|
||||
*/
|
||||
public void setHtml4ModeCompatibleWithXhtml1Schemata(
|
||||
boolean html4ModeCompatibleWithXhtml1Schemata) {
|
||||
this.html4ModeCompatibleWithXhtml1Schemata = html4ModeCompatibleWithXhtml1Schemata;
|
||||
}
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
// For the token handler to call
|
||||
|
@ -890,10 +872,6 @@ public class Tokenizer implements Locator {
|
|||
metaBoundaryPassed = true;
|
||||
}
|
||||
|
||||
void turnOnAdditionalHtml4Errors() {
|
||||
html4 = true;
|
||||
}
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
HtmlAttributes emptyAttributes() {
|
||||
|
@ -1292,39 +1270,20 @@ public class Tokenizer implements Locator {
|
|||
// ]NOCPP]
|
||||
if (attributeName != null) {
|
||||
// [NOCPP[
|
||||
if (html4) {
|
||||
if (attributeName.isBoolean()) {
|
||||
if (html4ModeCompatibleWithXhtml1Schemata) {
|
||||
attributes.addAttribute(attributeName,
|
||||
attributeName.getLocal(AttributeName.HTML),
|
||||
xmlnsPolicy);
|
||||
} else {
|
||||
attributes.addAttribute(attributeName, "", xmlnsPolicy);
|
||||
}
|
||||
} else {
|
||||
if (AttributeName.BORDER != attributeName) {
|
||||
err("Attribute value omitted for a non-boolean attribute. (HTML4-only error.)");
|
||||
attributes.addAttribute(attributeName, "", xmlnsPolicy);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (AttributeName.SRC == attributeName
|
||||
|| AttributeName.HREF == attributeName) {
|
||||
warn("Attribute \u201C"
|
||||
+ attributeName.getLocal(AttributeName.HTML)
|
||||
+ "\u201D without an explicit value seen. The attribute may be dropped by IE7.");
|
||||
}
|
||||
// ]NOCPP]
|
||||
attributes.addAttribute(attributeName,
|
||||
Portability.newEmptyString()
|
||||
// [NOCPP[
|
||||
, xmlnsPolicy
|
||||
// ]NOCPP]
|
||||
// CPPONLY: , attributeLine
|
||||
);
|
||||
// [NOCPP[
|
||||
if (AttributeName.SRC == attributeName
|
||||
|| AttributeName.HREF == attributeName) {
|
||||
warn("Attribute \u201C"
|
||||
+ attributeName.getLocal(AttributeName.HTML)
|
||||
+ "\u201D without an explicit value seen. The attribute may be dropped by IE7.");
|
||||
}
|
||||
// ]NOCPP]
|
||||
attributes.addAttribute(attributeName,
|
||||
Portability.newEmptyString()
|
||||
// [NOCPP[
|
||||
, xmlnsPolicy
|
||||
// ]NOCPP]
|
||||
// CPPONLY: , attributeLine
|
||||
);
|
||||
attributeName = null;
|
||||
} else {
|
||||
clearStrBufAfterUse();
|
||||
|
@ -1344,12 +1303,6 @@ public class Tokenizer implements Locator {
|
|||
// CPPONLY: if (mViewSource) {
|
||||
// CPPONLY: mViewSource.MaybeLinkifyAttributeValue(attributeName, val);
|
||||
// CPPONLY: }
|
||||
// [NOCPP[
|
||||
if (!endTag && html4 && html4ModeCompatibleWithXhtml1Schemata
|
||||
&& attributeName.isCaseFolded()) {
|
||||
val = newAsciiLowerCaseStringFromString(val);
|
||||
}
|
||||
// ]NOCPP]
|
||||
attributes.addAttribute(attributeName, val
|
||||
// [NOCPP[
|
||||
, xmlnsPolicy
|
||||
|
@ -1365,21 +1318,6 @@ public class Tokenizer implements Locator {
|
|||
|
||||
// [NOCPP[
|
||||
|
||||
private static String newAsciiLowerCaseStringFromString(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
char[] buf = new char[str.length()];
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
c += 0x20;
|
||||
}
|
||||
buf[i] = c;
|
||||
}
|
||||
return new String(buf);
|
||||
}
|
||||
|
||||
protected void startErrorReporting() throws SAXException {
|
||||
|
||||
}
|
||||
|
@ -2134,9 +2072,6 @@ public class Tokenizer implements Locator {
|
|||
*/
|
||||
// CPPONLY: MOZ_FALLTHROUGH;
|
||||
default:
|
||||
// [NOCPP[
|
||||
errHtml4NonNameInUnquotedAttribute(c);
|
||||
// ]NOCPP]
|
||||
/*
|
||||
* Anything else Append the current input
|
||||
* character to the current attribute's value.
|
||||
|
@ -2293,9 +2228,6 @@ public class Tokenizer implements Locator {
|
|||
* flag of the current tag token. Emit the current
|
||||
* tag token.
|
||||
*/
|
||||
// [NOCPP[
|
||||
errHtml4XmlVoidSyntax();
|
||||
// ]NOCPP]
|
||||
state = transition(state, emitCurrentTagToken(true, pos), reconsume, pos);
|
||||
if (shouldSuspend) {
|
||||
break stateloop;
|
||||
|
@ -2395,9 +2327,6 @@ public class Tokenizer implements Locator {
|
|||
*/
|
||||
// CPPONLY: MOZ_FALLTHROUGH;
|
||||
default:
|
||||
// [NOCPP]
|
||||
errHtml4NonNameInUnquotedAttribute(c);
|
||||
// ]NOCPP]
|
||||
/*
|
||||
* Anything else Append the current input
|
||||
* character to the current attribute's value.
|
||||
|
@ -6933,7 +6862,6 @@ public class Tokenizer implements Locator {
|
|||
line = 1;
|
||||
// CPPONLY: attributeLine = 1;
|
||||
// [NOCPP[
|
||||
html4 = false;
|
||||
metaBoundaryPassed = false;
|
||||
wantsComments = tokenHandler.wantsComments();
|
||||
if (!newAttributesEachTime) {
|
||||
|
@ -6985,16 +6913,9 @@ public class Tokenizer implements Locator {
|
|||
protected void errSlashNotFollowedByGt() throws SAXException {
|
||||
}
|
||||
|
||||
protected void errHtml4XmlVoidSyntax() throws SAXException {
|
||||
}
|
||||
|
||||
protected void errNoSpaceBetweenAttributes() throws SAXException {
|
||||
}
|
||||
|
||||
protected void errHtml4NonNameInUnquotedAttribute(char c)
|
||||
throws SAXException {
|
||||
}
|
||||
|
||||
protected void errLtOrEqualsOrGraveInUnquotedAttributeOrNull(char c)
|
||||
throws SAXException {
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Henri Sivonen
|
||||
* Copyright (c) 2007-2015 Mozilla Foundation
|
||||
* Copyright (c) 2007-2017 Mozilla Foundation
|
||||
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
|
||||
* Foundation, and Opera Software ASA.
|
||||
*
|
||||
|
@ -52,7 +52,6 @@ import nu.validator.htmlparser.annotation.Literal;
|
|||
import nu.validator.htmlparser.annotation.Local;
|
||||
import nu.validator.htmlparser.annotation.NoLength;
|
||||
import nu.validator.htmlparser.annotation.NsUri;
|
||||
import nu.validator.htmlparser.common.DoctypeExpectation;
|
||||
import nu.validator.htmlparser.common.DocumentMode;
|
||||
import nu.validator.htmlparser.common.DocumentModeHandler;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
|
@ -301,17 +300,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
|
||||
// end pseudo enums
|
||||
|
||||
// [NOCPP[
|
||||
|
||||
private final static String[] HTML4_PUBLIC_IDS = {
|
||||
"-//W3C//DTD HTML 4.0 Frameset//EN",
|
||||
"-//W3C//DTD HTML 4.0 Transitional//EN",
|
||||
"-//W3C//DTD HTML 4.0//EN", "-//W3C//DTD HTML 4.01 Frameset//EN",
|
||||
"-//W3C//DTD HTML 4.01 Transitional//EN",
|
||||
"-//W3C//DTD HTML 4.01//EN" };
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
@Literal private final static String[] QUIRKY_PUBLIC_IDS = {
|
||||
"+//silmaril//dtd html pro v0r11 19970101//",
|
||||
"-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
|
||||
|
@ -389,8 +377,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
|
||||
private DocumentModeHandler documentModeHandler;
|
||||
|
||||
private DoctypeExpectation doctypeExpectation = DoctypeExpectation.HTML;
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
private boolean scriptingEnabled = false;
|
||||
|
@ -458,8 +444,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
|
||||
private final Map<String, LocatorImpl> idLocations = new HashMap<String, LocatorImpl>();
|
||||
|
||||
private boolean html4;
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
protected TreeBuilder() {
|
||||
|
@ -609,7 +593,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
formPointer = null;
|
||||
headPointer = null;
|
||||
// [NOCPP[
|
||||
html4 = false;
|
||||
idLocations.clear();
|
||||
wantingComments = wantsComments();
|
||||
// ]NOCPP]
|
||||
|
@ -750,161 +733,50 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
Portability.releaseString(emptyString);
|
||||
// [NOCPP[
|
||||
}
|
||||
switch (doctypeExpectation) {
|
||||
case HTML:
|
||||
// ]NOCPP]
|
||||
if (isQuirky(name, publicIdentifier, systemIdentifier,
|
||||
forceQuirks)) {
|
||||
errQuirkyDoctype();
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE,
|
||||
publicIdentifier, systemIdentifier, false);
|
||||
} else if (isAlmostStandards(publicIdentifier,
|
||||
systemIdentifier)) {
|
||||
errAlmostStandardsDoctype();
|
||||
documentModeInternal(
|
||||
DocumentMode.ALMOST_STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, false);
|
||||
} else {
|
||||
// [NOCPP[
|
||||
if ((Portability.literalEqualsString(
|
||||
"-//W3C//DTD HTML 4.0//EN", publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString(
|
||||
"http://www.w3.org/TR/REC-html40/strict.dtd",
|
||||
systemIdentifier)))
|
||||
|| (Portability.literalEqualsString(
|
||||
"-//W3C//DTD HTML 4.01//EN",
|
||||
publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString(
|
||||
"http://www.w3.org/TR/html4/strict.dtd",
|
||||
systemIdentifier)))
|
||||
|| (Portability.literalEqualsString(
|
||||
"-//W3C//DTD XHTML 1.0 Strict//EN",
|
||||
publicIdentifier) && Portability.literalEqualsString(
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd",
|
||||
systemIdentifier))
|
||||
|| (Portability.literalEqualsString(
|
||||
"-//W3C//DTD XHTML 1.1//EN",
|
||||
publicIdentifier) && Portability.literalEqualsString(
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd",
|
||||
systemIdentifier))
|
||||
|
||||
) {
|
||||
warn("Obsolete doctype. Expected \u201C<!DOCTYPE html>\u201D.");
|
||||
} else if (!((systemIdentifier == null || Portability.literalEqualsString(
|
||||
"about:legacy-compat", systemIdentifier)) && publicIdentifier == null)) {
|
||||
err("Legacy doctype. Expected \u201C<!DOCTYPE html>\u201D.");
|
||||
}
|
||||
// ]NOCPP]
|
||||
documentModeInternal(DocumentMode.STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, false);
|
||||
}
|
||||
// [NOCPP[
|
||||
break;
|
||||
case HTML401_STRICT:
|
||||
html4 = true;
|
||||
tokenizer.turnOnAdditionalHtml4Errors();
|
||||
if (isQuirky(name, publicIdentifier, systemIdentifier,
|
||||
forceQuirks)) {
|
||||
err("Quirky doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE,
|
||||
publicIdentifier, systemIdentifier, true);
|
||||
} else if (isAlmostStandards(publicIdentifier,
|
||||
systemIdentifier)) {
|
||||
err("Almost standards mode doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
documentModeInternal(
|
||||
DocumentMode.ALMOST_STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, true);
|
||||
} else {
|
||||
if ("-//W3C//DTD HTML 4.01//EN".equals(publicIdentifier)) {
|
||||
if (!"http://www.w3.org/TR/html4/strict.dtd".equals(systemIdentifier)) {
|
||||
warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
}
|
||||
} else {
|
||||
err("The doctype was not the HTML 4.01 Strict doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
}
|
||||
documentModeInternal(DocumentMode.STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, true);
|
||||
}
|
||||
break;
|
||||
case HTML401_TRANSITIONAL:
|
||||
html4 = true;
|
||||
tokenizer.turnOnAdditionalHtml4Errors();
|
||||
if (isQuirky(name, publicIdentifier, systemIdentifier,
|
||||
forceQuirks)) {
|
||||
err("Quirky doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE,
|
||||
publicIdentifier, systemIdentifier, true);
|
||||
} else if (isAlmostStandards(publicIdentifier,
|
||||
systemIdentifier)) {
|
||||
if ("-//W3C//DTD HTML 4.01 Transitional//EN".equals(publicIdentifier)
|
||||
&& systemIdentifier != null) {
|
||||
if (!"http://www.w3.org/TR/html4/loose.dtd".equals(systemIdentifier)) {
|
||||
warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
|
||||
}
|
||||
} else {
|
||||
err("The doctype was not a non-quirky HTML 4.01 Transitional doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
|
||||
}
|
||||
documentModeInternal(
|
||||
DocumentMode.ALMOST_STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, true);
|
||||
} else {
|
||||
err("The doctype was not the HTML 4.01 Transitional doctype. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
|
||||
documentModeInternal(DocumentMode.STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, true);
|
||||
}
|
||||
break;
|
||||
case AUTO:
|
||||
html4 = isHtml4Doctype(publicIdentifier);
|
||||
if (html4) {
|
||||
tokenizer.turnOnAdditionalHtml4Errors();
|
||||
}
|
||||
if (isQuirky(name, publicIdentifier, systemIdentifier,
|
||||
forceQuirks)) {
|
||||
err("Quirky doctype. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE,
|
||||
publicIdentifier, systemIdentifier, html4);
|
||||
} else if (isAlmostStandards(publicIdentifier,
|
||||
systemIdentifier)) {
|
||||
errAlmostStandardsDoctype();
|
||||
documentModeInternal(
|
||||
DocumentMode.ALMOST_STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, html4);
|
||||
} else {
|
||||
if ("-//W3C//DTD HTML 4.01//EN".equals(publicIdentifier)) {
|
||||
if (!"http://www.w3.org/TR/html4/strict.dtd".equals(systemIdentifier)) {
|
||||
warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
}
|
||||
} else if ("-//W3C//DTD XHTML 1.0 Strict//EN".equals(publicIdentifier)) {
|
||||
if (!"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".equals(systemIdentifier)) {
|
||||
warn("The doctype did not contain the system identifier prescribed by the XHTML 1.0 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\u201D.");
|
||||
}
|
||||
} else if ("//W3C//DTD XHTML 1.1//EN".equals(publicIdentifier)) {
|
||||
if (!"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd".equals(systemIdentifier)) {
|
||||
warn("The doctype did not contain the system identifier prescribed by the XHTML 1.1 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\u201D.");
|
||||
}
|
||||
} else if (!((systemIdentifier == null || Portability.literalEqualsString(
|
||||
"about:legacy-compat", systemIdentifier)) && publicIdentifier == null)) {
|
||||
err("Unexpected doctype. Expected, e.g., \u201C<!DOCTYPE html>\u201D.");
|
||||
}
|
||||
documentModeInternal(DocumentMode.STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, html4);
|
||||
}
|
||||
break;
|
||||
case NO_DOCTYPE_ERRORS:
|
||||
if (isQuirky(name, publicIdentifier, systemIdentifier,
|
||||
forceQuirks)) {
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE,
|
||||
publicIdentifier, systemIdentifier, false);
|
||||
} else if (isAlmostStandards(publicIdentifier,
|
||||
systemIdentifier)) {
|
||||
documentModeInternal(
|
||||
DocumentMode.ALMOST_STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, false);
|
||||
} else {
|
||||
documentModeInternal(DocumentMode.STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// ]NOCPP]
|
||||
if (isQuirky(name, publicIdentifier, systemIdentifier,
|
||||
forceQuirks)) {
|
||||
errQuirkyDoctype();
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE,
|
||||
publicIdentifier, systemIdentifier);
|
||||
} else if (isAlmostStandards(publicIdentifier,
|
||||
systemIdentifier)) {
|
||||
errAlmostStandardsDoctype();
|
||||
documentModeInternal(
|
||||
DocumentMode.ALMOST_STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier);
|
||||
} else {
|
||||
// [NOCPP[
|
||||
if ((Portability.literalEqualsString(
|
||||
"-//W3C//DTD HTML 4.0//EN", publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString(
|
||||
"http://www.w3.org/TR/REC-html40/strict.dtd",
|
||||
systemIdentifier)))
|
||||
|| (Portability.literalEqualsString(
|
||||
"-//W3C//DTD HTML 4.01//EN",
|
||||
publicIdentifier) && (systemIdentifier == null || Portability.literalEqualsString(
|
||||
"http://www.w3.org/TR/html4/strict.dtd",
|
||||
systemIdentifier)))
|
||||
|| (Portability.literalEqualsString(
|
||||
"-//W3C//DTD XHTML 1.0 Strict//EN",
|
||||
publicIdentifier) && Portability.literalEqualsString(
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd",
|
||||
systemIdentifier))
|
||||
|| (Portability.literalEqualsString(
|
||||
"-//W3C//DTD XHTML 1.1//EN",
|
||||
publicIdentifier) && Portability.literalEqualsString(
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd",
|
||||
systemIdentifier))
|
||||
|
||||
) {
|
||||
warn("Obsolete doctype. Expected \u201C<!DOCTYPE html>\u201D.");
|
||||
} else if (!((systemIdentifier == null || Portability.literalEqualsString(
|
||||
"about:legacy-compat", systemIdentifier)) && publicIdentifier == null)) {
|
||||
err("Legacy doctype. Expected \u201C<!DOCTYPE html>\u201D.");
|
||||
}
|
||||
// ]NOCPP]
|
||||
documentModeInternal(DocumentMode.STANDARDS_MODE,
|
||||
publicIdentifier, systemIdentifier);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -924,19 +796,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
return;
|
||||
}
|
||||
|
||||
// [NOCPP[
|
||||
|
||||
private boolean isHtml4Doctype(String publicIdentifier) {
|
||||
if (publicIdentifier != null
|
||||
&& (Arrays.binarySearch(TreeBuilder.HTML4_PUBLIC_IDS,
|
||||
publicIdentifier) > -1)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ]NOCPP]
|
||||
|
||||
public final void comment(@NoLength char[] buf, int start, int length)
|
||||
throws SAXException {
|
||||
needToDropLF = false;
|
||||
|
@ -1119,22 +978,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
* Parse error.
|
||||
*/
|
||||
// [NOCPP[
|
||||
switch (doctypeExpectation) {
|
||||
case AUTO:
|
||||
err("Non-space characters found without seeing a doctype first. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
|
||||
break;
|
||||
case HTML:
|
||||
// XXX figure out a way to report this in the Gecko View Source case
|
||||
err("Non-space characters found without seeing a doctype first. Expected \u201C<!DOCTYPE html>\u201D.");
|
||||
break;
|
||||
case HTML401_STRICT:
|
||||
err("Non-space characters found without seeing a doctype first. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
break;
|
||||
case HTML401_TRANSITIONAL:
|
||||
err("Non-space characters found without seeing a doctype first. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
|
||||
break;
|
||||
case NO_DOCTYPE_ERRORS:
|
||||
}
|
||||
// XXX figure out a way to report this in the Gecko View Source case
|
||||
err("Non-space characters found without seeing a doctype first. Expected \u201C<!DOCTYPE html>\u201D.");
|
||||
// ]NOCPP]
|
||||
/*
|
||||
*
|
||||
|
@ -1142,7 +987,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
*/
|
||||
documentModeInternal(
|
||||
DocumentMode.QUIRKS_MODE, null,
|
||||
null, false);
|
||||
null);
|
||||
/*
|
||||
* Then, switch to the root element mode of
|
||||
* the tree construction stage
|
||||
|
@ -1406,28 +1251,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
* Parse error.
|
||||
*/
|
||||
// [NOCPP[
|
||||
switch (doctypeExpectation) {
|
||||
case AUTO:
|
||||
err("End of file seen without seeing a doctype first. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
|
||||
break;
|
||||
case HTML:
|
||||
err("End of file seen without seeing a doctype first. Expected \u201C<!DOCTYPE html>\u201D.");
|
||||
break;
|
||||
case HTML401_STRICT:
|
||||
err("End of file seen without seeing a doctype first. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
break;
|
||||
case HTML401_TRANSITIONAL:
|
||||
err("End of file seen without seeing a doctype first. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
|
||||
break;
|
||||
case NO_DOCTYPE_ERRORS:
|
||||
}
|
||||
err("End of file seen without seeing a doctype first. Expected \u201C<!DOCTYPE html>\u201D.");
|
||||
// ]NOCPP]
|
||||
/*
|
||||
*
|
||||
* Set the document to quirks mode.
|
||||
*/
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE, null, null,
|
||||
false);
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE, null, null);
|
||||
/*
|
||||
* Then, switch to the root element mode of the tree
|
||||
* construction stage
|
||||
|
@ -2770,31 +2600,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
/*
|
||||
* Parse error.
|
||||
*/
|
||||
// [NOCPP[
|
||||
switch (doctypeExpectation) {
|
||||
case AUTO:
|
||||
err("Start tag seen without seeing a doctype first. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
|
||||
break;
|
||||
case HTML:
|
||||
// ]NOCPP]
|
||||
errStartTagWithoutDoctype();
|
||||
// [NOCPP[
|
||||
break;
|
||||
case HTML401_STRICT:
|
||||
err("Start tag seen without seeing a doctype first. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
break;
|
||||
case HTML401_TRANSITIONAL:
|
||||
err("Start tag seen without seeing a doctype first. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
|
||||
break;
|
||||
case NO_DOCTYPE_ERRORS:
|
||||
}
|
||||
// ]NOCPP]
|
||||
errStartTagWithoutDoctype();
|
||||
/*
|
||||
*
|
||||
* Set the document to quirks mode.
|
||||
*/
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE, null, null,
|
||||
false);
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE, null, null);
|
||||
/*
|
||||
* Then, switch to the root element mode of the tree
|
||||
* construction stage
|
||||
|
@ -3980,31 +3791,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
/*
|
||||
* Parse error.
|
||||
*/
|
||||
// [NOCPP[
|
||||
switch (doctypeExpectation) {
|
||||
case AUTO:
|
||||
err("End tag seen without seeing a doctype first. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
|
||||
break;
|
||||
case HTML:
|
||||
// ]NOCPP]
|
||||
errEndTagSeenWithoutDoctype();
|
||||
// [NOCPP[
|
||||
break;
|
||||
case HTML401_STRICT:
|
||||
err("End tag seen without seeing a doctype first. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
|
||||
break;
|
||||
case HTML401_TRANSITIONAL:
|
||||
err("End tag seen without seeing a doctype first. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\u201D.");
|
||||
break;
|
||||
case NO_DOCTYPE_ERRORS:
|
||||
}
|
||||
// ]NOCPP]
|
||||
errEndTagSeenWithoutDoctype();
|
||||
/*
|
||||
*
|
||||
* Set the document to quirks mode.
|
||||
*/
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE, null, null,
|
||||
false);
|
||||
documentModeInternal(DocumentMode.QUIRKS_MODE, null, null);
|
||||
/*
|
||||
* Then, switch to the root element mode of the tree
|
||||
* construction stage
|
||||
|
@ -4235,7 +4027,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
}
|
||||
|
||||
private void documentModeInternal(DocumentMode m, String publicIdentifier,
|
||||
String systemIdentifier, boolean html4SpecificAdditionalErrorChecks)
|
||||
String systemIdentifier)
|
||||
throws SAXException {
|
||||
|
||||
if (isSrcdocDocument) {
|
||||
|
@ -4245,7 +4037,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
documentModeHandler.documentMode(
|
||||
DocumentMode.STANDARDS_MODE
|
||||
// [NOCPP[
|
||||
, null, null, false
|
||||
, null, null
|
||||
// ]NOCPP]
|
||||
);
|
||||
}
|
||||
|
@ -4257,14 +4049,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
documentModeHandler.documentMode(
|
||||
m
|
||||
// [NOCPP[
|
||||
, publicIdentifier, systemIdentifier,
|
||||
html4SpecificAdditionalErrorChecks
|
||||
, publicIdentifier, systemIdentifier
|
||||
// ]NOCPP]
|
||||
);
|
||||
}
|
||||
// [NOCPP[
|
||||
documentMode(m, publicIdentifier, systemIdentifier,
|
||||
html4SpecificAdditionalErrorChecks);
|
||||
documentMode(m, publicIdentifier, systemIdentifier);
|
||||
// ]NOCPP]
|
||||
}
|
||||
|
||||
|
@ -5208,25 +4998,21 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
for (int i = 0; i < len; i++) {
|
||||
AttributeName name = attributes.getXmlnsAttributeName(i);
|
||||
if (name == AttributeName.XMLNS) {
|
||||
if (html4) {
|
||||
err("Attribute \u201Cxmlns\u201D not allowed here. (HTML4-only error.)");
|
||||
} else {
|
||||
String xmlns = attributes.getXmlnsValue(i);
|
||||
if (!ns.equals(xmlns)) {
|
||||
err("Bad value \u201C"
|
||||
+ xmlns
|
||||
+ "\u201D for the attribute \u201Cxmlns\u201D (only \u201C"
|
||||
+ ns + "\u201D permitted here).");
|
||||
switch (namePolicy) {
|
||||
case ALTER_INFOSET:
|
||||
// fall through
|
||||
case ALLOW:
|
||||
warn("Attribute \u201Cxmlns\u201D is not serializable as XML 1.0.");
|
||||
break;
|
||||
case FATAL:
|
||||
fatal("Attribute \u201Cxmlns\u201D is not serializable as XML 1.0.");
|
||||
break;
|
||||
}
|
||||
String xmlns = attributes.getXmlnsValue(i);
|
||||
if (!ns.equals(xmlns)) {
|
||||
err("Bad value \u201C"
|
||||
+ xmlns
|
||||
+ "\u201D for the attribute \u201Cxmlns\u201D (only \u201C"
|
||||
+ ns + "\u201D permitted here).");
|
||||
switch (namePolicy) {
|
||||
case ALTER_INFOSET:
|
||||
// fall through
|
||||
case ALLOW:
|
||||
warn("Attribute \u201Cxmlns\u201D is not serializable as XML 1.0.");
|
||||
break;
|
||||
case FATAL:
|
||||
fatal("Attribute \u201Cxmlns\u201D is not serializable as XML 1.0.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (ns != "http://www.w3.org/1999/xhtml"
|
||||
|
@ -5872,7 +5658,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
// [NOCPP[
|
||||
|
||||
protected void documentMode(DocumentMode m, String publicIdentifier,
|
||||
String systemIdentifier, boolean html4SpecificAdditionalErrorChecks)
|
||||
String systemIdentifier)
|
||||
throws SAXException {
|
||||
|
||||
}
|
||||
|
@ -5993,16 +5779,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
|||
|
||||
// [NOCPP[
|
||||
|
||||
/**
|
||||
* Sets the doctypeExpectation.
|
||||
*
|
||||
* @param doctypeExpectation
|
||||
* the doctypeExpectation to set
|
||||
*/
|
||||
public void setDoctypeExpectation(DoctypeExpectation doctypeExpectation) {
|
||||
this.doctypeExpectation = doctypeExpectation;
|
||||
}
|
||||
|
||||
public void setNamePolicy(XmlViolationPolicy namePolicy) {
|
||||
this.namePolicy = namePolicy;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2007 Henri Sivonen
|
||||
* Copyright (c) 2007-2015 Mozilla Foundation
|
||||
* Copyright (c) 2007-2017 Mozilla Foundation
|
||||
* Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla
|
||||
* Foundation, and Opera Software ASA.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2007 Henri Sivonen
|
||||
* Copyright (c) 2007-2015 Mozilla Foundation
|
||||
* Copyright (c) 2007-2017 Mozilla Foundation
|
||||
* Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla
|
||||
* Foundation, and Opera Software ASA.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Henri Sivonen
|
||||
* Copyright (c) 2007-2015 Mozilla Foundation
|
||||
* Copyright (c) 2007-2017 Mozilla Foundation
|
||||
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
|
||||
* Foundation, and Opera Software ASA.
|
||||
*
|
||||
|
@ -235,15 +235,13 @@ void nsHtml5TreeBuilder::doctype(nsAtom* name, nsHtml5String publicIdentifier,
|
|||
emptyString.Release();
|
||||
if (isQuirky(name, publicIdentifier, systemIdentifier, forceQuirks)) {
|
||||
errQuirkyDoctype();
|
||||
documentModeInternal(QUIRKS_MODE, publicIdentifier, systemIdentifier,
|
||||
false);
|
||||
documentModeInternal(QUIRKS_MODE, publicIdentifier, systemIdentifier);
|
||||
} else if (isAlmostStandards(publicIdentifier, systemIdentifier)) {
|
||||
errAlmostStandardsDoctype();
|
||||
documentModeInternal(ALMOST_STANDARDS_MODE, publicIdentifier,
|
||||
systemIdentifier, false);
|
||||
systemIdentifier);
|
||||
} else {
|
||||
documentModeInternal(STANDARDS_MODE, publicIdentifier, systemIdentifier,
|
||||
false);
|
||||
documentModeInternal(STANDARDS_MODE, publicIdentifier, systemIdentifier);
|
||||
}
|
||||
mode = BEFORE_HTML;
|
||||
return;
|
||||
|
@ -379,7 +377,7 @@ void nsHtml5TreeBuilder::characters(const char16_t* buf, int32_t start,
|
|||
default: {
|
||||
switch (mode) {
|
||||
case INITIAL: {
|
||||
documentModeInternal(QUIRKS_MODE, nullptr, nullptr, false);
|
||||
documentModeInternal(QUIRKS_MODE, nullptr, nullptr);
|
||||
mode = BEFORE_HTML;
|
||||
i--;
|
||||
continue;
|
||||
|
@ -551,7 +549,7 @@ void nsHtml5TreeBuilder::eof() {
|
|||
for (;;) {
|
||||
switch (mode) {
|
||||
case INITIAL: {
|
||||
documentModeInternal(QUIRKS_MODE, nullptr, nullptr, false);
|
||||
documentModeInternal(QUIRKS_MODE, nullptr, nullptr);
|
||||
mode = BEFORE_HTML;
|
||||
continue;
|
||||
}
|
||||
|
@ -1853,7 +1851,7 @@ starttagloop:
|
|||
}
|
||||
case INITIAL: {
|
||||
errStartTagWithoutDoctype();
|
||||
documentModeInternal(QUIRKS_MODE, nullptr, nullptr, false);
|
||||
documentModeInternal(QUIRKS_MODE, nullptr, nullptr);
|
||||
mode = BEFORE_HTML;
|
||||
continue;
|
||||
}
|
||||
|
@ -3099,7 +3097,7 @@ void nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName) {
|
|||
}
|
||||
case INITIAL: {
|
||||
errEndTagSeenWithoutDoctype();
|
||||
documentModeInternal(QUIRKS_MODE, nullptr, nullptr, false);
|
||||
documentModeInternal(QUIRKS_MODE, nullptr, nullptr);
|
||||
mode = BEFORE_HTML;
|
||||
continue;
|
||||
}
|
||||
|
@ -3333,9 +3331,9 @@ bool nsHtml5TreeBuilder::isSecondOnStackBody() {
|
|||
return currentPtr >= 1 && stack[1]->getGroup() == nsHtml5TreeBuilder::BODY;
|
||||
}
|
||||
|
||||
void nsHtml5TreeBuilder::documentModeInternal(
|
||||
nsHtml5DocumentMode m, nsHtml5String publicIdentifier,
|
||||
nsHtml5String systemIdentifier, bool html4SpecificAdditionalErrorChecks) {
|
||||
void nsHtml5TreeBuilder::documentModeInternal(nsHtml5DocumentMode m,
|
||||
nsHtml5String publicIdentifier,
|
||||
nsHtml5String systemIdentifier) {
|
||||
if (isSrcdocDocument) {
|
||||
quirks = false;
|
||||
this->documentMode(STANDARDS_MODE);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Henri Sivonen
|
||||
* Copyright (c) 2007-2015 Mozilla Foundation
|
||||
* Copyright (c) 2007-2017 Mozilla Foundation
|
||||
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
|
||||
* Foundation, and Opera Software ASA.
|
||||
*
|
||||
|
@ -380,8 +380,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState {
|
|||
bool isSecondOnStackBody();
|
||||
void documentModeInternal(nsHtml5DocumentMode m,
|
||||
nsHtml5String publicIdentifier,
|
||||
nsHtml5String systemIdentifier,
|
||||
bool html4SpecificAdditionalErrorChecks);
|
||||
nsHtml5String systemIdentifier);
|
||||
bool isAlmostStandards(nsHtml5String publicIdentifier,
|
||||
nsHtml5String systemIdentifier);
|
||||
bool isQuirky(nsAtom* name, nsHtml5String publicIdentifier,
|
||||
|
|
Загрузка…
Ссылка в новой задаче