Skip to content

Commit

Permalink
Fixes isaacs#233 (processing instruction ending with "?")
Browse files Browse the repository at this point in the history
Recognizes "?" while in the PROC_INST_ENDING state, and keeps it in that state after adding "?" to the body
  • Loading branch information
arista committed May 15, 2018
1 parent 5aee216 commit 8a00e75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/sax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/issue-233.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require(__dirname).test({
xml: '<r><?Is this legal XML??></r>',
expect: [
['opentagstart', {'name': 'R', 'attributes': {}}],
['opentag', {'name': 'R', 'attributes': {}, 'isSelfClosing': false}],
[ 'processinginstruction', { name: 'Is', body: 'this legal XML?' } ],
['closetag', 'R']
]
})

0 comments on commit 8a00e75

Please sign in to comment.