Skip to content

Commit

Permalink
[tokenizer] fixed handling non-existent entities
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Aug 18, 2013
1 parent b60cf04 commit e45e4ec
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/Tokenizer.js
Expand Up @@ -500,7 +500,7 @@ Tokenizer.prototype._parseNamedEntityStrict = function(){
if(map.hasOwnProperty(entity)){
//TODO attributes
this._cbs.ontext(map[entity]);
this._sectionStart = this._index;
this._sectionStart = this._index + 1;
}
}
};
Expand All @@ -518,7 +518,7 @@ Tokenizer.prototype._parseLegacyEntity = function(){

if(legacyMap.hasOwnProperty(entity)){
this._cbs.ontext(legacyMap[entity]);
this._sectionStart += limit + 1;
this._sectionStart += limit + 2;
break;
} else {
limit--;
Expand All @@ -533,7 +533,6 @@ Tokenizer.prototype._stateInNamedEntity = function(c){
this._parseLegacyEntity();
}
this._state = this._baseState;
this._sectionStart++;
} else if((c < "a" || c > "z") && (c < "A" || c > "Z") && (c < "0" || c > "9")){
if(this._xmlMode);
/*else if(
Expand All @@ -543,9 +542,11 @@ Tokenizer.prototype._stateInNamedEntity = function(c){
) {
if(c !== "="){
this._parseNamedEntityStrict(); //TODO
this._sectionStart--; //include the current character in the section
}
} else*/ {
}*/ else {
this._parseLegacyEntity();
this._sectionStart--;
}
this._state = this._baseState;
this._index--;
Expand Down Expand Up @@ -871,7 +872,7 @@ Tokenizer.prototype._handleTrailingData = function(){
this._cbs.onclosetag(data);
} else if(this._state === IN_NAMED_ENTITY && !this._xmlMode){
this._parseLegacyEntity();
if(this._sectionStart < this._index){
if(--this._sectionStart < this._index){
this._state = this._baseState;
this._handleTrailingData();
}
Expand Down

0 comments on commit e45e4ec

Please sign in to comment.