diff --git a/lib/Tokenizer.js b/lib/Tokenizer.js index ffeaa46..8b58cc4 100644 --- a/lib/Tokenizer.js +++ b/lib/Tokenizer.js @@ -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; } } }; @@ -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--; @@ -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( @@ -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--; @@ -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(); }