From 8a00e75ed2998302c3ddfbd25c0caf9f7c62cc38 Mon Sep 17 00:00:00 2001 From: arista Date: Tue, 15 May 2018 09:43:41 -0400 Subject: [PATCH] Fixes #233 (processing instruction ending with "?") Recognizes "?" while in the PROC_INST_ENDING state, and keeps it in that state after adding "?" to the body --- lib/sax.js | 2 ++ test/issue-233.js | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 test/issue-233.js 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..cce37965 --- /dev/null +++ b/test/issue-233.js @@ -0,0 +1,9 @@ +require(__dirname).test({ + xml: '', + expect: [ + ['opentagstart', {'name': 'R', 'attributes': {}}], + ['opentag', {'name': 'R', 'attributes': {}, 'isSelfClosing': false}], + [ 'processinginstruction', { name: 'Is', body: 'this legal XML?' } ], + ['closetag', 'R'] + ] +})