sax 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +3 -0
- package/lib/sax.js +31 -9
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The ISC License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2023 Isaac Z. Schlueter and Contributors
|
|
4
4
|
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
6
|
purpose with or without fee is hereby granted, provided that the above
|
|
@@ -19,7 +19,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
19
19
|
`String.fromCodePoint` by Mathias Bynens used according to terms of MIT
|
|
20
20
|
License, as follows:
|
|
21
21
|
|
|
22
|
-
Copyright (c) 2010-
|
|
22
|
+
Copyright (c) 2010-2023 Mathias Bynens <https://mathiasbynens.be/>
|
|
23
23
|
|
|
24
24
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
25
25
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -106,6 +106,9 @@ Settings supported:
|
|
|
106
106
|
* `strictEntities` - Boolean. If true, only parse [predefined XML
|
|
107
107
|
entities](http://www.w3.org/TR/REC-xml/#sec-predefined-ent)
|
|
108
108
|
(`&`, `'`, `>`, `<`, and `"`)
|
|
109
|
+
* `unquotedAttributeValues` - Boolean. If true, then unquoted
|
|
110
|
+
attribute values are allowed. Defaults to `false` when `strict`
|
|
111
|
+
is true, `true` otherwise.
|
|
109
112
|
|
|
110
113
|
## Methods
|
|
111
114
|
|
package/lib/sax.js
CHANGED
|
@@ -71,6 +71,12 @@
|
|
|
71
71
|
parser.ns = Object.create(rootNS)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// disallow unquoted attribute values if not otherwise configured
|
|
75
|
+
// and strict mode is true
|
|
76
|
+
if (parser.opt.unquotedAttributeValues === undefined) {
|
|
77
|
+
parser.opt.unquotedAttributeValues = !strict;
|
|
78
|
+
}
|
|
79
|
+
|
|
74
80
|
// mostly just for error reporting
|
|
75
81
|
parser.trackPosition = parser.opt.position !== false
|
|
76
82
|
if (parser.trackPosition) {
|
|
@@ -1090,15 +1096,23 @@
|
|
|
1090
1096
|
continue
|
|
1091
1097
|
|
|
1092
1098
|
case S.SGML_DECL:
|
|
1099
|
+
if (parser.sgmlDecl + c === '--') {
|
|
1100
|
+
parser.state = S.COMMENT
|
|
1101
|
+
parser.comment = ''
|
|
1102
|
+
parser.sgmlDecl = ''
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
if (parser.doctype && parser.doctype !== true) {
|
|
1107
|
+
parser.sgmlDecl += c
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1093
1111
|
if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
|
|
1094
1112
|
emitNode(parser, 'onopencdata')
|
|
1095
1113
|
parser.state = S.CDATA
|
|
1096
1114
|
parser.sgmlDecl = ''
|
|
1097
1115
|
parser.cdata = ''
|
|
1098
|
-
} else if (parser.sgmlDecl + c === '--') {
|
|
1099
|
-
parser.state = S.COMMENT
|
|
1100
|
-
parser.comment = ''
|
|
1101
|
-
parser.sgmlDecl = ''
|
|
1102
1116
|
} else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
|
|
1103
1117
|
parser.state = S.DOCTYPE
|
|
1104
1118
|
if (parser.doctype || parser.sawRoot) {
|
|
@@ -1152,10 +1166,14 @@
|
|
|
1152
1166
|
continue
|
|
1153
1167
|
|
|
1154
1168
|
case S.DOCTYPE_DTD:
|
|
1155
|
-
parser.doctype += c
|
|
1156
1169
|
if (c === ']') {
|
|
1170
|
+
parser.doctype += c
|
|
1157
1171
|
parser.state = S.DOCTYPE
|
|
1172
|
+
} else if (c === '<') {
|
|
1173
|
+
parser.state = S.OPEN_WAKA
|
|
1174
|
+
parser.startTagPosition = parser.position
|
|
1158
1175
|
} else if (isQuote(c)) {
|
|
1176
|
+
parser.doctype += c
|
|
1159
1177
|
parser.state = S.DOCTYPE_DTD_QUOTED
|
|
1160
1178
|
parser.q = c
|
|
1161
1179
|
}
|
|
@@ -1198,6 +1216,8 @@
|
|
|
1198
1216
|
// which is a comment of " blah -- bloo "
|
|
1199
1217
|
parser.comment += '--' + c
|
|
1200
1218
|
parser.state = S.COMMENT
|
|
1219
|
+
} else if (parser.doctype && parser.doctype !== true) {
|
|
1220
|
+
parser.state = S.DOCTYPE_DTD
|
|
1201
1221
|
} else {
|
|
1202
1222
|
parser.state = S.TEXT
|
|
1203
1223
|
}
|
|
@@ -1365,7 +1385,9 @@
|
|
|
1365
1385
|
parser.q = c
|
|
1366
1386
|
parser.state = S.ATTRIB_VALUE_QUOTED
|
|
1367
1387
|
} else {
|
|
1368
|
-
|
|
1388
|
+
if (!parser.opt.unquotedAttributeValues) {
|
|
1389
|
+
error(parser, 'Unquoted attribute value')
|
|
1390
|
+
}
|
|
1369
1391
|
parser.state = S.ATTRIB_VALUE_UNQUOTED
|
|
1370
1392
|
parser.attribValue = c
|
|
1371
1393
|
}
|
|
@@ -1483,13 +1505,13 @@
|
|
|
1483
1505
|
}
|
|
1484
1506
|
|
|
1485
1507
|
if (c === ';') {
|
|
1486
|
-
|
|
1487
|
-
|
|
1508
|
+
var parsedEntity = parseEntity(parser)
|
|
1509
|
+
if (parser.opt.unparsedEntities && !Object.values(sax.XML_ENTITIES).includes(parsedEntity)) {
|
|
1488
1510
|
parser.entity = ''
|
|
1489
1511
|
parser.state = returnState
|
|
1490
1512
|
parser.write(parsedEntity)
|
|
1491
1513
|
} else {
|
|
1492
|
-
parser[buffer] +=
|
|
1514
|
+
parser[buffer] += parsedEntity
|
|
1493
1515
|
parser.entity = ''
|
|
1494
1516
|
parser.state = returnState
|
|
1495
1517
|
}
|
package/package.json
CHANGED