Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #91 Bad calls to strictFail

  • Loading branch information...
commit 3b74c16503572d4216d93c867853fed846cffe55 1 parent 4719381
@isaacs authored
Showing with 8 additions and 7 deletions.
  1. +5 −3 lib/sax.js
  2. +3 −4 test/issue-47.js
View
8 lib/sax.js
@@ -631,6 +631,8 @@ function end (parser) {
}
function strictFail (parser, message) {
+ if (typeof parser !== 'object' || !(parser instanceof SAXParser))
+ throw new Error('bad call to strictFail');
if (parser.strict) error(parser, message)
}
@@ -928,7 +930,7 @@ function write (chunk) {
parser.startTagPosition = parser.position
} else {
if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot))
- strictFail("Text data outside of root node.")
+ strictFail(parser, "Text data outside of root node.")
if (c === "&") parser.state = S.TEXT_ENTITY
else parser.textNode += c
}
@@ -1264,7 +1266,7 @@ function write (chunk) {
case S.CLOSE_TAG_SAW_WHITE:
if (is(whitespace, c)) continue
if (c === ">") closeTag(parser)
- else strictFail("Invalid characters in closing tag")
+ else strictFail(parser, "Invalid characters in closing tag")
continue
case S.TEXT_ENTITY:
@@ -1290,7 +1292,7 @@ function write (chunk) {
}
else if (is(entity, c)) parser.entity += c
else {
- strictFail("Invalid character entity")
+ strictFail(parser, "Invalid character entity")
parser[buffer] += "&" + parser.entity + c
parser.entity = ""
parser.state = returnState
View
7 test/issue-47.js
@@ -2,11 +2,10 @@
require(__dirname).test
( { xml : '<a href="query.svc?x=1&y=2&z=3"/>'
, expect : [
- [ "attribute", { name:'href', value:"query.svc?x=1&y=2&z=3"} ],
- [ "opentag", { name: "a", attributes: { href:"query.svc?x=1&y=2&z=3"}, isSelfClosing: true } ],
- [ "closetag", "a" ]
+ [ "attribute", { name:'HREF', value:"query.svc?x=1&y=2&z=3"} ],
+ [ "opentag", { name: "A", attributes: { HREF:"query.svc?x=1&y=2&z=3"}, isSelfClosing: true } ],
+ [ "closetag", "A" ]
]
- , strict : true
, opt : {}
}
)
Please sign in to comment.
Something went wrong with that request. Please try again.