Socket
Socket
Sign inDemoInstall

sax

Package Overview
Dependencies
0
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 1.2.3

72

lib/sax.js

@@ -265,11 +265,4 @@ ;(function (sax) { // wrapper for non-node envs

// character classes and tokens
var whitespace = '\r\n\t '
// this really needs to be replaced with character classes.
// XML allows all manner of ridiculous numbers and digits.
// (Letter | "_" | ":")
var quote = '\'"'
var attribEnd = whitespace + '>'
var CDATA = '[CDATA['

@@ -281,5 +274,2 @@ var DOCTYPE = 'DOCTYPE'

// turn all the string character sets into character class objects.
whitespace = charClass(whitespace)
// http://www.w3.org/TR/REC-xml/#NT-NameStartChar

@@ -298,12 +288,14 @@ // This implementation works on strings, a single character at a time

quote = charClass(quote)
attribEnd = charClass(attribEnd)
function isWhitespace (c) {
return c === ' ' || c === '\n' || c === '\r' || c === '\t'
}
function charClass (str) {
return str.split('').reduce(function (s, c) {
s[c] = true
return s
}, {})
function isQuote (c) {
return c === '"' || c === '\''
}
function isAttribEnd (c) {
return c === '>' || isWhitespace(c)
}
function isMatch (regex, c) {

@@ -313,6 +305,2 @@ return regex.test(c)

function is (charclass, c) {
return charclass[c]
}
function notMatch (regex, c) {

@@ -322,6 +310,2 @@ return !isMatch(regex, c)

function not (charclass, c) {
return !is(charclass, c)
}
var S = 0

@@ -969,3 +953,3 @@ sax.STATE = {

parser.startTagPosition = parser.position
} else if (not(whitespace, c)) {
} else if (!isWhitespace(c)) {
// have to process this as a text node.

@@ -1056,3 +1040,3 @@ // weird, but happens.

} else {
if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot)) {
if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
strictFail(parser, 'Text data outside of root node.')

@@ -1091,3 +1075,3 @@ }

parser.sgmlDecl = ''
} else if (is(whitespace, c)) {
} else if (isWhitespace(c)) {
// wait for it...

@@ -1137,3 +1121,3 @@ } else if (isMatch(nameStart, c)) {

parser.state = S.TEXT
} else if (is(quote, c)) {
} else if (isQuote(c)) {
parser.state = S.SGML_DECL_QUOTED

@@ -1163,3 +1147,3 @@ parser.sgmlDecl += c

parser.state = S.DOCTYPE_DTD
} else if (is(quote, c)) {
} else if (isQuote(c)) {
parser.state = S.DOCTYPE_QUOTED

@@ -1183,3 +1167,3 @@ parser.q = c

parser.state = S.DOCTYPE
} else if (is(quote, c)) {
} else if (isQuote(c)) {
parser.state = S.DOCTYPE_DTD_QUOTED

@@ -1268,3 +1252,3 @@ parser.q = c

parser.state = S.PROC_INST_ENDING
} else if (is(whitespace, c)) {
} else if (isWhitespace(c)) {
parser.state = S.PROC_INST_BODY

@@ -1277,3 +1261,3 @@ } else {

case S.PROC_INST_BODY:
if (!parser.procInstBody && is(whitespace, c)) {
if (!parser.procInstBody && isWhitespace(c)) {
continue

@@ -1311,3 +1295,3 @@ } else if (c === '?') {

} else {
if (not(whitespace, c)) {
if (!isWhitespace(c)) {
strictFail(parser, 'Invalid character in tag name')

@@ -1332,3 +1316,3 @@ }

// haven't read the attribute name yet.
if (is(whitespace, c)) {
if (isWhitespace(c)) {
continue

@@ -1356,3 +1340,3 @@ } else if (c === '>') {

openTag(parser)
} else if (is(whitespace, c)) {
} else if (isWhitespace(c)) {
parser.state = S.ATTRIB_NAME_SAW_WHITE

@@ -1369,3 +1353,3 @@ } else if (isMatch(nameBody, c)) {

parser.state = S.ATTRIB_VALUE
} else if (is(whitespace, c)) {
} else if (isWhitespace(c)) {
continue

@@ -1394,5 +1378,5 @@ } else {

case S.ATTRIB_VALUE:
if (is(whitespace, c)) {
if (isWhitespace(c)) {
continue
} else if (is(quote, c)) {
} else if (isQuote(c)) {
parser.q = c

@@ -1422,3 +1406,3 @@ parser.state = S.ATTRIB_VALUE_QUOTED

case S.ATTRIB_VALUE_CLOSED:
if (is(whitespace, c)) {
if (isWhitespace(c)) {
parser.state = S.ATTRIB

@@ -1440,3 +1424,3 @@ } else if (c === '>') {

case S.ATTRIB_VALUE_UNQUOTED:
if (not(attribEnd, c)) {
if (!isAttribEnd(c)) {
if (c === '&') {

@@ -1459,3 +1443,3 @@ parser.state = S.ATTRIB_VALUE_ENTITY_U

if (!parser.tagName) {
if (is(whitespace, c)) {
if (isWhitespace(c)) {
continue

@@ -1481,3 +1465,3 @@ } else if (notMatch(nameStart, c)) {

} else {
if (not(whitespace, c)) {
if (!isWhitespace(c)) {
strictFail(parser, 'Invalid tagname in closing tag')

@@ -1490,3 +1474,3 @@ }

case S.CLOSE_TAG_SAW_WHITE:
if (is(whitespace, c)) {
if (isWhitespace(c)) {
continue

@@ -1493,0 +1477,0 @@ }

@@ -5,3 +5,3 @@ {

"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"version": "1.2.2",
"version": "1.2.3",
"main": "lib/sax.js",

@@ -11,3 +11,6 @@ "license": "ISC",

"test": "tap test/*.js --cov -j4",
"posttest": "standard -F test/*.js lib/*.js"
"posttest": "standard -F test/*.js lib/*.js",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --all; git push origin --tags"
},

@@ -14,0 +17,0 @@ "repository": "git://github.com/isaacs/sax-js.git",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc