Skip to content

Commit

Permalink
Merge pull request #28 from HTMLParseErrorWG/null-bogus-comment
Browse files Browse the repository at this point in the history
Add null character error reporting for bogus doctype and comment per current spec changes
  • Loading branch information
inikulin authored Aug 22, 2017
2 parents 2d6e16b + b1f9308 commit 0b8f660
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/tokenizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1592,8 +1592,10 @@ _[BOGUS_COMMENT_STATE] = function bogusCommentState(cp) {
this._emitEOFToken();
}

else if (cp === $.NULL)
else if (cp === $.NULL) {
this._err(ERR.unexpectedNullCharacter);
this.currentToken.data += unicode.REPLACEMENT_CHARACTER;
}

else
this.currentToken.data += toChar(cp);
Expand Down Expand Up @@ -1943,7 +1945,7 @@ _[AFTER_DOCTYPE_NAME_STATE] = function afterDoctypeNameState(cp) {
else if (!this._ensureHibernation()) {
this._err(ERR.invalidCharacterSequenceAfterDoctypeName);
this.currentToken.forceQuirks = true;
this.state = BOGUS_DOCTYPE_STATE;
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
}
};

Expand Down Expand Up @@ -1983,7 +1985,7 @@ _[AFTER_DOCTYPE_PUBLIC_KEYWORD_STATE] = function afterDoctypePublicKeywordState(
else {
this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
this.currentToken.forceQuirks = true;
this.state = BOGUS_DOCTYPE_STATE;
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
}
};

Expand Down Expand Up @@ -2118,7 +2120,7 @@ _[AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE] = function afterDoctypePublicIdentifier
else {
this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
this.currentToken.forceQuirks = true;
this.state = BOGUS_DOCTYPE_STATE;
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
}
};

Expand Down Expand Up @@ -2194,7 +2196,7 @@ _[AFTER_DOCTYPE_SYSTEM_KEYWORD_STATE] = function afterDoctypeSystemKeywordState(
else {
this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
this.currentToken.forceQuirks = true;
this.state = BOGUS_DOCTYPE_STATE;
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
}
};

Expand Down Expand Up @@ -2317,7 +2319,7 @@ _[AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE] = function afterDoctypeSystemIdentifier

else {
this._err(ERR.unexpectedCharacterAfterDoctypeSystemIdentifier);
this.state = BOGUS_DOCTYPE_STATE;
this._reconsumeInState(BOGUS_DOCTYPE_STATE);
}
};

Expand All @@ -2330,6 +2332,9 @@ _[BOGUS_DOCTYPE_STATE] = function bogusDoctypeState(cp) {
this.state = DATA_STATE;
}

else if (cp === $.NULL)
this._err(ERR.unexpectedNullCharacter);

else if (cp === $.EOF) {
this._emitCurrentToken();
this._emitEOFToken();
Expand Down

0 comments on commit 0b8f660

Please sign in to comment.