diff --git a/lib/sax.js b/lib/sax.js index 795d607e..53999e6c 100644 --- a/lib/sax.js +++ b/lib/sax.js @@ -1263,6 +1263,8 @@ }) parser.procInstName = parser.procInstBody = '' parser.state = S.TEXT + } else if (c === '?') { + parser.procInstBody += '?' } else { parser.procInstBody += '?' + c parser.state = S.PROC_INST_BODY diff --git a/test/issue-233.js b/test/issue-233.js new file mode 100644 index 00000000..c93d3b37 --- /dev/null +++ b/test/issue-233.js @@ -0,0 +1,10 @@ +require(__dirname).test({ + xml: '', + expect: [ + ['opentagstart', {'name': 'R', 'attributes': {}}], + ['opentag', {'name': 'R', 'attributes': {}, 'isSelfClosing': false}], + [ 'processinginstruction', { name: 'Is', body: 'this legal XML?' } ], + [ 'processinginstruction', { name: 'Is', body: 'this legal XML? ' } ], + ['closetag', 'R'] + ] +})