sax 1.2.1 → 1.2.2

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/lib/sax.js CHANGED
@@ -267,8 +267,6 @@
267
267
 
268
268
  // this really needs to be replaced with character classes.
269
269
  // XML allows all manner of ridiculous numbers and digits.
270
- var number = '0124356789'
271
- var letter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
272
270
 
273
271
  // (Letter | "_" | ":")
274
272
  var quote = '\'"'
@@ -281,8 +279,6 @@
281
279
 
282
280
  // turn all the string character sets into character class objects.
283
281
  whitespace = charClass(whitespace)
284
- number = charClass(number)
285
- letter = charClass(letter)
286
282
 
287
283
  // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
288
284
  // This implementation works on strings, a single character at a time
@@ -292,10 +288,10 @@
292
288
  // is left as an exercise for the reader.
293
289
  var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
294
290
 
295
- var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/
291
+ var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
296
292
 
297
293
  var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
298
- var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/
294
+ var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
299
295
 
300
296
  quote = charClass(quote)
301
297
  attribEnd = charClass(attribEnd)
@@ -307,12 +303,16 @@
307
303
  }, {})
308
304
  }
309
305
 
310
- function isRegExp (c) {
311
- return Object.prototype.toString.call(c) === '[object RegExp]'
306
+ function isMatch (regex, c) {
307
+ return regex.test(c)
312
308
  }
313
309
 
314
310
  function is (charclass, c) {
315
- return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
311
+ return charclass[c]
312
+ }
313
+
314
+ function notMatch (regex, c) {
315
+ return !isMatch(regex, c)
316
316
  }
317
317
 
318
318
  function not (charclass, c) {
@@ -998,9 +998,11 @@
998
998
  while (true) {
999
999
  c = charAt(chunk, i++)
1000
1000
  parser.c = c
1001
+
1001
1002
  if (!c) {
1002
1003
  break
1003
1004
  }
1005
+
1004
1006
  if (parser.trackPosition) {
1005
1007
  parser.position++
1006
1008
  if (c === '\n') {
@@ -1010,6 +1012,7 @@
1010
1012
  parser.column++
1011
1013
  }
1012
1014
  }
1015
+
1013
1016
  switch (parser.state) {
1014
1017
  case S.BEGIN:
1015
1018
  parser.state = S.BEGIN_WHITESPACE
@@ -1080,7 +1083,7 @@
1080
1083
  parser.sgmlDecl = ''
1081
1084
  } else if (is(whitespace, c)) {
1082
1085
  // wait for it...
1083
- } else if (is(nameStart, c)) {
1086
+ } else if (isMatch(nameStart, c)) {
1084
1087
  parser.state = S.OPEN_TAG
1085
1088
  parser.tagName = c
1086
1089
  } else if (c === '/') {
@@ -1283,7 +1286,7 @@
1283
1286
  continue
1284
1287
 
1285
1288
  case S.OPEN_TAG:
1286
- if (is(nameBody, c)) {
1289
+ if (isMatch(nameBody, c)) {
1287
1290
  parser.tagName += c
1288
1291
  } else {
1289
1292
  newTag(parser)
@@ -1318,7 +1321,7 @@
1318
1321
  openTag(parser)
1319
1322
  } else if (c === '/') {
1320
1323
  parser.state = S.OPEN_TAG_SLASH
1321
- } else if (is(nameStart, c)) {
1324
+ } else if (isMatch(nameStart, c)) {
1322
1325
  parser.attribName = c
1323
1326
  parser.attribValue = ''
1324
1327
  parser.state = S.ATTRIB_NAME
@@ -1337,7 +1340,7 @@
1337
1340
  openTag(parser)
1338
1341
  } else if (is(whitespace, c)) {
1339
1342
  parser.state = S.ATTRIB_NAME_SAW_WHITE
1340
- } else if (is(nameBody, c)) {
1343
+ } else if (isMatch(nameBody, c)) {
1341
1344
  parser.attribName += c
1342
1345
  } else {
1343
1346
  strictFail(parser, 'Invalid attribute name')
@@ -1360,7 +1363,7 @@
1360
1363
  parser.attribName = ''
1361
1364
  if (c === '>') {
1362
1365
  openTag(parser)
1363
- } else if (is(nameStart, c)) {
1366
+ } else if (isMatch(nameStart, c)) {
1364
1367
  parser.attribName = c
1365
1368
  parser.state = S.ATTRIB_NAME
1366
1369
  } else {
@@ -1404,7 +1407,7 @@
1404
1407
  openTag(parser)
1405
1408
  } else if (c === '/') {
1406
1409
  parser.state = S.OPEN_TAG_SLASH
1407
- } else if (is(nameStart, c)) {
1410
+ } else if (isMatch(nameStart, c)) {
1408
1411
  strictFail(parser, 'No whitespace between attributes')
1409
1412
  parser.attribName = c
1410
1413
  parser.attribValue = ''
@@ -1435,7 +1438,7 @@
1435
1438
  if (!parser.tagName) {
1436
1439
  if (is(whitespace, c)) {
1437
1440
  continue
1438
- } else if (not(nameStart, c)) {
1441
+ } else if (notMatch(nameStart, c)) {
1439
1442
  if (parser.script) {
1440
1443
  parser.script += '</' + c
1441
1444
  parser.state = S.SCRIPT
@@ -1447,7 +1450,7 @@
1447
1450
  }
1448
1451
  } else if (c === '>') {
1449
1452
  closeTag(parser)
1450
- } else if (is(nameBody, c)) {
1453
+ } else if (isMatch(nameBody, c)) {
1451
1454
  parser.tagName += c
1452
1455
  } else if (parser.script) {
1453
1456
  parser.script += '</' + parser.tagName
@@ -1498,7 +1501,7 @@
1498
1501
  parser[buffer] += parseEntity(parser)
1499
1502
  parser.entity = ''
1500
1503
  parser.state = returnState
1501
- } else if (is(parser.entity.length ? entityBody : entityStart, c)) {
1504
+ } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
1502
1505
  parser.entity += c
1503
1506
  } else {
1504
1507
  strictFail(parser, 'Invalid character in entity name')
@@ -1521,6 +1524,7 @@
1521
1524
  }
1522
1525
 
1523
1526
  /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
1527
+ /* istanbul ignore next */
1524
1528
  if (!String.fromCodePoint) {
1525
1529
  (function () {
1526
1530
  var stringFromCharCode = String.fromCharCode
@@ -1562,6 +1566,7 @@
1562
1566
  }
1563
1567
  return result
1564
1568
  }
1569
+ /* istanbul ignore next */
1565
1570
  if (Object.defineProperty) {
1566
1571
  Object.defineProperty(String, 'fromCodePoint', {
1567
1572
  value: fromCodePoint,
package/package.json CHANGED
@@ -2,22 +2,21 @@
2
2
  "name": "sax",
3
3
  "description": "An evented streaming XML parser in JavaScript",
4
4
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
5
- "version": "1.2.1",
5
+ "version": "1.2.2",
6
6
  "main": "lib/sax.js",
7
7
  "license": "ISC",
8
8
  "scripts": {
9
- "test": "tap test/*.js --cov",
9
+ "test": "tap test/*.js --cov -j4",
10
10
  "posttest": "standard -F test/*.js lib/*.js"
11
11
  },
12
12
  "repository": "git://github.com/isaacs/sax-js.git",
13
13
  "files": [
14
14
  "lib/sax.js",
15
15
  "LICENSE",
16
- "LICENSE-W3C.html",
17
16
  "README.md"
18
17
  ],
19
18
  "devDependencies": {
20
- "standard": "^5.3.1",
21
- "tap": "^5.2.0"
19
+ "standard": "^8.6.0",
20
+ "tap": "^10.0.2"
22
21
  }
23
22
  }
package/LICENSE-W3C.html DELETED
@@ -1,188 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="generator" content="HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 13), see www.w3.org" /><title>W3C Software Notice and License</title><link rel="stylesheet" href="/2008/site/css/minimum" type="text/css" media="handheld, all" /><style type="text/css" media="print, screen and (min-width: 481px)" xml:space="preserve">
3
- @import url("/2008/site/css/advanced");
4
- </style><link href="/2008/site/css/minimum" rel="stylesheet" type="text/css" media="handheld, only screen and (max-device-width: 480px)" /><meta name="viewport" content="width=device-width" /><link rel="stylesheet" href="/2008/site/css/print" type="text/css" media="print" /><link rel="shortcut icon" href="/2008/site/images/favicon.ico" type="image/x-icon" /></head><body id="www-w3-org" class="w3c_public"><div id="w3c_container">
5
-
6
-
7
-
8
- <div id="w3c_mast">
9
- <h1 class="logo">
10
- <a tabindex="2" accesskey="1" href="/"><img src="/2008/site/images/logo-w3c-mobile-lg" width="90" height="53" alt="W3C" /></a>
11
- <span class="alt-logo">W3C</span>
12
- </h1>
13
-
14
- <div id="w3c_nav">
15
-
16
-
17
-
18
- <form action="/Help/search" method="get" enctype="application/x-www-form-urlencoded"><div class="w3c_sec_nav"><!-- --></div><ul class="main_nav"><li class="first-item">
19
- <a href="/standards/">Standards</a>
20
- </li><li>
21
- <a href="/participate/">Participate</a>
22
- </li><li>
23
- <a href="/Consortium/membership">Membership</a>
24
- </li><li class="last-item">
25
- <a href="/Consortium/">About W3C</a>
26
- </li><li class="search-item">
27
- <div id="search-form">
28
- <input tabindex="3" class="text" name="q" value="" title="Search" type="text" />
29
- <button id="search-submit" name="search-submit" type="submit"><img class="submit" src="/2008/site/images/search-button" alt="Search" width="21" height="17" /></button>
30
- </div>
31
- </li></ul></form>
32
- </div>
33
-
34
- </div>
35
-
36
-
37
- <div id="w3c_main">
38
- <div id="w3c_logo_shadow" class="w3c_leftCol">
39
- <img height="32" alt="" src="/2008/site/images/logo-shadow" />
40
- </div>
41
-
42
- <div class="w3c_leftCol"><h2 class="offscreen">Site Navigation</h2>
43
- <h3 class="category"><span class="ribbon"><a href="/Consortium/Legal/ipr-notice.html" title="Up to Policies and Legal Information">Policies and Legal Information <img src="/2008/site/images/header-link" alt="Header link" width="13" height="13" class="header-link" /></a></span></h3>
44
- <ul class="theme">
45
- <li><a href="/Consortium/Legal/2008/04-testsuite-copyright.html">Licenses for W3C Test Suites</a></li>
46
- <li><a href="/2004/10/27-testcases.html">Policies for Contribution of Test Cases to W3C</a></li>
47
- <li><a href="/Consortium/Legal/IPR-FAQ-20000620.html">Intellectual Rights FAQ</a></li>
48
- <li><a href="/Consortium/Legal/privacy-statement-20000612.html">W3C Privacy Statements</a></li>
49
- <li><a href="/Consortium/Legal/2002/copyright-documents-20021231.html">W3C Document License</a></li>
50
- <li><a href="/Consortium/Legal/2002/trademarks-20021231.html">W3C Trademarks and Generic Terms</a></li>
51
- <li><a href="/Consortium/Legal/2002/trademark-license-20021231.html">W3C&#xAE; Trademark and Service Mark License</a></li>
52
- <li><a class="current">W3C Software Notice and License</a></li>
53
- <li><a href="/Consortium/Legal/2002/collaborators-agreement-20021231.html">W3C Invited Expert and Collaborators Agreement</a></li>
54
- <li><a href="/Consortium/Persistence.html">W3C URI Persistence Policy</a></li>
55
- <li><a href="/1999/10/21-mirroring-policy.html">Mirroring the W3C Site</a></li>
56
- <li><a href="/Consortium/Legal/2006/08-copyright-translations.html">Translations of the Copyright Notice</a></li>
57
- </ul>
58
- <br /></div>
59
- <div class="w3c_mainCol">
60
- <div id="w3c_crumbs">
61
- <div id="w3c_crumbs_frame">
62
- <ul class="bct"> <!-- .bct / Breadcrumbs -->
63
- <li class="skip"><a tabindex="1" accesskey="2" title="Skip to content (e.g., when browsing via audio)" href="#w3c_content_body">Skip</a></li>
64
- <li><a href="/">W3C</a>&#xA0;<span class="cr">&#xBB;</span>&#xA0;</li>
65
- <li><a href="/Consortium/">About&#xA0;W3C</a>&#xA0;<span class="cr">&#xBB;</span>&#xA0;</li>
66
- <li><a href="/Consortium/facts.html">Facts&#xA0;About&#xA0;W3C</a>&#xA0;<span class="cr">&#xBB;</span>&#xA0;</li>
67
- <li><a href="/Consortium/Legal/ipr-notice.html">Policies&#xA0;and&#xA0;Legal&#xA0;Information</a>&#xA0;<span class="cr">&#xBB;</span>&#xA0;</li>
68
- <li class="current">W3C Software Notice and License</li>
69
- </ul>
70
- </div>
71
- </div>
72
- <h1 class="title">W3C Software Notice and License</h1>
73
- <div id="w3c_content_body">
74
- <div class="line">
75
- <p class="intro tPadding">This work (and included software, documentation such as READMEs, or other
76
- related items) is being provided by the copyright holders under the following
77
- license.</p>
78
- <h2>License</h2>
79
-
80
- <p class="tPadding">
81
- By obtaining, using and/or copying this work, you (the licensee)
82
- agree that you have read, understood, and will comply with the following
83
- terms and conditions.</p>
84
-
85
- <p>Permission to copy, modify, and distribute this software and its
86
- documentation, with or without modification,&#xA0;for any purpose and without
87
- fee or royalty is hereby granted, provided that you include the following on
88
- ALL copies of the software and documentation or portions thereof, including
89
- modifications:</p>
90
-
91
- <ul class="show_items"><li>The full text of this NOTICE in a location viewable to users of the
92
- redistributed or derivative work.</li><li>Any pre-existing intellectual property disclaimers, notices, or terms
93
- and conditions. If none exist, the <a href="copyright-software-short-notice-20021231.html">W3C Software Short
94
- Notice</a> should be included (hypertext is preferred, text is permitted)
95
- within the body of any redistributed or derivative code.</li><li>Notice of any changes or modifications to the files, including the date
96
- changes were made. (We recommend you provide URIs to the location from
97
- which the code is derived.)</li></ul>
98
-
99
- <h2>Disclaimers</h2>
100
-
101
- <p>THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS
102
- MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
103
- LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
104
- PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE
105
- ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.</p>
106
-
107
- <p>COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
108
- CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
109
- DOCUMENTATION.</p>
110
-
111
- <p>The name and trademarks of copyright holders may NOT be used in
112
- advertising or publicity pertaining to the software without specific, written
113
- prior permission. Title to copyright in this software and any associated
114
- documentation will at all times remain with copyright holders.</p>
115
-
116
- <h2>Notes</h2>
117
-
118
- <p>This version: http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231</p>
119
-
120
- <p>This formulation of W3C's notice and license became active on December 31
121
- 2002. This version removes the copyright ownership notice such that this
122
- license can be used with materials other than those owned by the W3C,
123
- reflects that ERCIM is now a host of the W3C, includes references to this
124
- specific dated version of the license, and removes the ambiguous grant of
125
- "use". Otherwise, this version is the same as the <a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">previous
126
- version</a> and is written so as to preserve the <a href="http://www.gnu.org/philosophy/license-list.html#GPLCompatibleLicenses">Free
127
- Software Foundation's assessment of GPL compatibility</a> and <a href="http://www.opensource.org/licenses/W3C.php">OSI's certification</a>
128
- under the <a href="http://www.opensource.org/docs/definition.php">Open Source
129
- Definition</a>.</p>
130
- </div>
131
- </div>
132
- </div>
133
- </div>
134
-
135
-
136
-
137
- </div><div id="w3c_footer">
138
- <div id="w3c_footer-inner">
139
- <h2 class="offscreen">Footer Navigation</h2>
140
- <div class="w3c_footer-nav">
141
- <h3>Navigation</h3>
142
- <ul class="footer_top_nav"><li>
143
- <a href="/">Home</a>
144
- </li><li>
145
- <a href="/standards/">Standards</a>
146
- </li><li>
147
- <a href="/participate/">Participate</a>
148
- </li><li>
149
- <a href="/Consortium/membership">Membership</a>
150
- </li><li class="last-item">
151
- <a href="/Consortium/">About W3C</a>
152
- </li></ul>
153
- </div>
154
- <div class="w3c_footer-nav">
155
- <h3>Contact W3C</h3>
156
- <ul class="footer_bottom_nav"><li>
157
- <a href="/Consortium/contact">Contact</a>
158
- </li><li>
159
- <a accesskey="0" href="/Help/">Help and FAQ</a>
160
- </li><li>
161
- <a href="/Consortium/sponsor/">Sponsor / Donate</a>
162
- </li><li>
163
- <a href="/Consortium/siteindex">Site Map</a>
164
- </li><li>
165
- <address id="w3c_signature">
166
- <a href="http://lists.w3.org/Archives/Public/site-comments/">Feedback</a></address>
167
- </li></ul>
168
- </div>
169
- <div class="w3c_footer-nav">
170
- <h3>W3C Updates</h3>
171
- <ul class="footer_follow_nav"><li>
172
- <a href="http://twitter.com/W3C" title="Follow W3C on Twitter">
173
- <img src="/2008/site/images/twitter-bird" alt="Twitter" width="78" height="83" class="social-icon" />
174
- </a>
175
- <a href="http://identi.ca/w3c" title="See W3C on Identica">
176
- <img src="/2008/site/images/identica-logo" alt="Identica" width="91" height="83" class="social-icon" />
177
- </a>
178
- </li></ul>
179
- </div>
180
- <p class="copyright">Copyright &#xA9; 2012 W3C <sup>&#xAE;</sup> (<a href="http://www.csail.mit.edu/">
181
- <acronym title="Massachusetts Institute of Technology">MIT</acronym>
182
- </a>, <a href="http://www.ercim.org/">
183
- <acronym title="European Research Consortium for Informatics and Mathematics"> ERCIM</acronym>
184
- </a>, <a href="http://www.keio.ac.jp/">Keio</a>) <a href="/Consortium/Legal/ipr-notice">Usage policies apply</a>.</p>
185
- </div>
186
- </div><!-- Generated from data/scripts.php, ../../smarty/{scripts.tpl} --><!-- At the bottom for performance reasons --><div id="w3c_scripts">
187
- <script type="text/javascript" src="/2008/site/js/main" xml:space="preserve"><!-- --></script>
188
- </div></body></html>