Skip to content

Commit

Permalink
Fixes sax-js bug 233 (processing instruction ending with "?")
Browse files Browse the repository at this point in the history
This is the fix for isaacs#233 , but fixed in our fork of the https://github.com/isaacs/sax-js repo since that repo doesn't seem to be getting any attention.  The equivalent PR in that repo is isaacs#234 - I've just copied the code here.
  • Loading branch information
arista committed Jun 12, 2018
1 parent b55f489 commit 732a8ec
Show file tree
Hide file tree
Showing 2 changed files with 12 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
10 changes: 10 additions & 0 deletions test/issue-233.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require(__dirname).test({
xml: '<r><?Is this legal XML??><?Is this legal XML? ?></r>',
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']
]
})

0 comments on commit 732a8ec

Please sign in to comment.