Skip to content

Commit

Permalink
Fix issue #68, infinite loop on unclosed comment
Browse files Browse the repository at this point in the history
  • Loading branch information
skypanther committed Jan 22, 2014
1 parent 9ddac14 commit bf83fc5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sax.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
break;
case '!':// <!doctype,<![CDATA,<!--
locator&&position(i);
end = parseDCC(source,i,domBuilder);
end = parseDCC(source,i,domBuilder,errorHandler);
break;
default:
if(i<0){
Expand Down Expand Up @@ -436,12 +436,13 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){
function _copy(source,target){
for(var n in source){target[n] = source[n]}
}
function parseDCC(source,start,domBuilder){//sure start with '<!'
function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
var next= source.charAt(start+2)
switch(next){
case '-':
if(source.charAt(start + 3) === '-'){
var end = source.indexOf('-->',start+4);
if(end === -1) errorHandler.fatalError("Unclosed comment");
//append comment source.substring(4,end)//<!--
domBuilder.comment(source,start+4,end-start-4);
return end+3;
Expand Down

0 comments on commit bf83fc5

Please sign in to comment.