Skip to content

Commit

Permalink
Don't treat XML declarations as Processing Instructions
Browse files Browse the repository at this point in the history
The XML declaration is not a processing instruction.

According to XML 1.0 (5th Edition), Section 2.6, the PI target names "xml",
"XML" and so on are reserved.

Production Rule 17 states:
> PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))

This fixes jindw#174.
  • Loading branch information
Holzhaus committed Jun 11, 2017
1 parent e0e40f6 commit 5f560e2
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 @@ -551,8 +551,9 @@ function parseInstruction(source,start,domBuilder){
if(end){
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
if(match){
var len = match[0].length;
domBuilder.processingInstruction(match[1], match[2]) ;
if(match[1].toLowerCase() !== 'xml'){//ignore XML declarations
domBuilder.processingInstruction(match[1], match[2]) ;
}
return end+2;
}else{//error
return -1;
Expand Down

0 comments on commit 5f560e2

Please sign in to comment.