ahmad-module 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ahmad-module might be problematic. Click here for more details.
- package/.bin/sshpk-conv +12 -0
- package/.bin/sshpk-conv.cmd +17 -0
- package/.bin/sshpk-conv.ps1 +28 -0
- package/.bin/sshpk-sign +12 -0
- package/.bin/sshpk-sign.cmd +17 -0
- package/.bin/sshpk-sign.ps1 +28 -0
- package/.bin/sshpk-verify +12 -0
- package/.bin/sshpk-verify.cmd +17 -0
- package/.bin/sshpk-verify.ps1 +28 -0
- package/.bin/uuid +12 -0
- package/.bin/uuid.cmd +17 -0
- package/.bin/uuid.ps1 +28 -0
- package/ajv/.tonic_example.js +20 -0
- package/ajv/LICENSE +22 -0
- package/ajv/README.md +1497 -0
- package/ajv/dist/ajv.bundle.js +7189 -0
- package/ajv/dist/ajv.min.js +3 -0
- package/ajv/dist/ajv.min.js.map +1 -0
- package/ajv/lib/ajv.d.ts +397 -0
- package/ajv/lib/ajv.js +506 -0
- package/ajv/lib/cache.js +26 -0
- package/ajv/lib/compile/async.js +90 -0
- package/ajv/lib/compile/equal.js +5 -0
- package/ajv/lib/compile/error_classes.js +34 -0
- package/ajv/lib/compile/formats.js +142 -0
- package/ajv/lib/compile/index.js +387 -0
- package/ajv/lib/compile/resolve.js +270 -0
- package/ajv/lib/compile/rules.js +66 -0
- package/ajv/lib/compile/schema_obj.js +9 -0
- package/ajv/lib/compile/ucs2length.js +20 -0
- package/ajv/lib/compile/util.js +239 -0
- package/ajv/lib/data.js +49 -0
- package/ajv/lib/definition_schema.js +37 -0
- package/ajv/lib/dot/_limit.jst +113 -0
- package/ajv/lib/dot/_limitItems.jst +12 -0
- package/ajv/lib/dot/_limitLength.jst +12 -0
- package/ajv/lib/dot/_limitProperties.jst +12 -0
- package/ajv/lib/dot/allOf.jst +32 -0
- package/ajv/lib/dot/anyOf.jst +46 -0
- package/ajv/lib/dot/coerce.def +51 -0
- package/ajv/lib/dot/comment.jst +9 -0
- package/ajv/lib/dot/const.jst +11 -0
- package/ajv/lib/dot/contains.jst +55 -0
- package/ajv/lib/dot/custom.jst +191 -0
- package/ajv/lib/dot/defaults.def +47 -0
- package/ajv/lib/dot/definitions.def +203 -0
- package/ajv/lib/dot/dependencies.jst +79 -0
- package/ajv/lib/dot/enum.jst +30 -0
- package/ajv/lib/dot/errors.def +194 -0
- package/ajv/lib/dot/format.jst +106 -0
- package/ajv/lib/dot/if.jst +73 -0
- package/ajv/lib/dot/items.jst +98 -0
- package/ajv/lib/dot/missing.def +39 -0
- package/ajv/lib/dot/multipleOf.jst +22 -0
- package/ajv/lib/dot/not.jst +43 -0
- package/ajv/lib/dot/oneOf.jst +54 -0
- package/ajv/lib/dot/pattern.jst +14 -0
- package/ajv/lib/dot/properties.jst +245 -0
- package/ajv/lib/dot/propertyNames.jst +52 -0
- package/ajv/lib/dot/ref.jst +85 -0
- package/ajv/lib/dot/required.jst +108 -0
- package/ajv/lib/dot/uniqueItems.jst +62 -0
- package/ajv/lib/dot/validate.jst +276 -0
- package/ajv/lib/dotjs/README.md +3 -0
- package/ajv/lib/dotjs/_limit.js +163 -0
- package/ajv/lib/dotjs/_limitItems.js +80 -0
- package/ajv/lib/dotjs/_limitLength.js +85 -0
- package/ajv/lib/dotjs/_limitProperties.js +80 -0
- package/ajv/lib/dotjs/allOf.js +42 -0
- package/ajv/lib/dotjs/anyOf.js +73 -0
- package/ajv/lib/dotjs/comment.js +14 -0
- package/ajv/lib/dotjs/const.js +56 -0
- package/ajv/lib/dotjs/contains.js +81 -0
- package/ajv/lib/dotjs/custom.js +228 -0
- package/ajv/lib/dotjs/dependencies.js +168 -0
- package/ajv/lib/dotjs/enum.js +66 -0
- package/ajv/lib/dotjs/format.js +150 -0
- package/ajv/lib/dotjs/if.js +103 -0
- package/ajv/lib/dotjs/index.js +33 -0
- package/ajv/lib/dotjs/items.js +140 -0
- package/ajv/lib/dotjs/multipleOf.js +80 -0
- package/ajv/lib/dotjs/not.js +84 -0
- package/ajv/lib/dotjs/oneOf.js +73 -0
- package/ajv/lib/dotjs/pattern.js +75 -0
- package/ajv/lib/dotjs/properties.js +335 -0
- package/ajv/lib/dotjs/propertyNames.js +81 -0
- package/ajv/lib/dotjs/ref.js +124 -0
- package/ajv/lib/dotjs/required.js +270 -0
- package/ajv/lib/dotjs/uniqueItems.js +86 -0
- package/ajv/lib/dotjs/validate.js +482 -0
- package/ajv/lib/keyword.js +146 -0
- package/ajv/lib/refs/data.json +17 -0
- package/ajv/lib/refs/json-schema-draft-04.json +149 -0
- package/ajv/lib/refs/json-schema-draft-06.json +154 -0
- package/ajv/lib/refs/json-schema-draft-07.json +168 -0
- package/ajv/lib/refs/json-schema-secure.json +94 -0
- package/ajv/package.json +106 -0
- package/ajv/scripts/.eslintrc.yml +3 -0
- package/ajv/scripts/bundle.js +61 -0
- package/ajv/scripts/compile-dots.js +73 -0
- package/ajv/scripts/info +10 -0
- package/ajv/scripts/prepare-tests +12 -0
- package/ajv/scripts/publish-built-version +32 -0
- package/ajv/scripts/travis-gh-pages +23 -0
- package/asn1/Jenkinsfile +65 -0
- package/asn1/LICENSE +19 -0
- package/asn1/README.md +50 -0
- package/asn1/lib/ber/errors.js +13 -0
- package/asn1/lib/ber/index.js +27 -0
- package/asn1/lib/ber/reader.js +262 -0
- package/asn1/lib/ber/types.js +36 -0
- package/asn1/lib/ber/writer.js +317 -0
- package/asn1/lib/index.js +20 -0
- package/asn1/package.json +31 -0
- package/assert-plus/AUTHORS +6 -0
- package/assert-plus/CHANGES.md +14 -0
- package/assert-plus/README.md +162 -0
- package/assert-plus/assert.js +211 -0
- package/assert-plus/package.json +23 -0
- package/asynckit/LICENSE +21 -0
- package/asynckit/README.md +233 -0
- package/asynckit/bench.js +76 -0
- package/asynckit/index.js +6 -0
- package/asynckit/lib/abort.js +29 -0
- package/asynckit/lib/async.js +34 -0
- package/asynckit/lib/defer.js +26 -0
- package/asynckit/lib/iterate.js +75 -0
- package/asynckit/lib/readable_asynckit.js +91 -0
- package/asynckit/lib/readable_parallel.js +25 -0
- package/asynckit/lib/readable_serial.js +25 -0
- package/asynckit/lib/readable_serial_ordered.js +29 -0
- package/asynckit/lib/state.js +37 -0
- package/asynckit/lib/streamify.js +141 -0
- package/asynckit/lib/terminator.js +29 -0
- package/asynckit/package.json +63 -0
- package/asynckit/parallel.js +43 -0
- package/asynckit/serial.js +17 -0
- package/asynckit/serialOrdered.js +75 -0
- package/asynckit/stream.js +21 -0
- package/aws-sign2/LICENSE +55 -0
- package/aws-sign2/README.md +4 -0
- package/aws-sign2/index.js +212 -0
- package/aws-sign2/package.json +17 -0
- package/aws4/.github/FUNDING.yml +3 -0
- package/aws4/.travis.yml +9 -0
- package/aws4/LICENSE +19 -0
- package/aws4/README.md +183 -0
- package/aws4/aws4.js +373 -0
- package/aws4/lru.js +96 -0
- package/aws4/package.json +17 -0
- package/axios/CHANGELOG.md +775 -0
- package/axios/LICENSE +19 -0
- package/axios/README.md +868 -0
- package/axios/SECURITY.md +5 -0
- package/axios/UPGRADE_GUIDE.md +162 -0
- package/axios/dist/axios.js +2193 -0
- package/axios/dist/axios.map +1 -0
- package/axios/dist/axios.min.js +3 -0
- package/axios/dist/axios.min.map +1 -0
- package/axios/index.d.ts +168 -0
- package/axios/index.js +1 -0
- package/axios/lib/adapters/README.md +37 -0
- package/axios/lib/adapters/http.js +331 -0
- package/axios/lib/adapters/xhr.js +189 -0
- package/axios/lib/axios.js +56 -0
- package/axios/lib/cancel/Cancel.js +19 -0
- package/axios/lib/cancel/CancelToken.js +57 -0
- package/axios/lib/cancel/isCancel.js +5 -0
- package/axios/lib/core/Axios.js +148 -0
- package/axios/lib/core/InterceptorManager.js +54 -0
- package/axios/lib/core/README.md +8 -0
- package/axios/lib/core/buildFullPath.js +20 -0
- package/axios/lib/core/createError.js +18 -0
- package/axios/lib/core/dispatchRequest.js +82 -0
- package/axios/lib/core/enhanceError.js +42 -0
- package/axios/lib/core/mergeConfig.js +87 -0
- package/axios/lib/core/settle.js +25 -0
- package/axios/lib/core/transformData.js +22 -0
- package/axios/lib/defaults.js +134 -0
- package/axios/lib/helpers/README.md +7 -0
- package/axios/lib/helpers/bind.js +11 -0
- package/axios/lib/helpers/buildURL.js +70 -0
- package/axios/lib/helpers/combineURLs.js +14 -0
- package/axios/lib/helpers/cookies.js +53 -0
- package/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/axios/lib/helpers/isAxiosError.js +11 -0
- package/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/axios/lib/helpers/parseHeaders.js +53 -0
- package/axios/lib/helpers/spread.js +27 -0
- package/axios/lib/helpers/validator.js +105 -0
- package/axios/lib/utils.js +349 -0
- package/axios/package.json +84 -0
- package/bcrypt-pbkdf/CONTRIBUTING.md +13 -0
- package/bcrypt-pbkdf/LICENSE +66 -0
- package/bcrypt-pbkdf/README.md +45 -0
- package/bcrypt-pbkdf/index.js +556 -0
- package/bcrypt-pbkdf/package.json +15 -0
- package/caseless/LICENSE +28 -0
- package/caseless/README.md +45 -0
- package/caseless/index.js +67 -0
- package/caseless/package.json +27 -0
- package/caseless/test.js +67 -0
- package/combined-stream/License +19 -0
- package/combined-stream/Readme.md +138 -0
- package/combined-stream/lib/combined_stream.js +208 -0
- package/combined-stream/package.json +25 -0
- package/combined-stream/yarn.lock +17 -0
- package/core-util-is/LICENSE +19 -0
- package/core-util-is/README.md +3 -0
- package/core-util-is/float.patch +604 -0
- package/core-util-is/lib/util.js +107 -0
- package/core-util-is/package.json +32 -0
- package/core-util-is/test.js +68 -0
- package/dashdash/CHANGES.md +364 -0
- package/dashdash/LICENSE.txt +24 -0
- package/dashdash/README.md +574 -0
- package/dashdash/etc/dashdash.bash_completion.in +389 -0
- package/dashdash/lib/dashdash.js +1055 -0
- package/dashdash/package.json +26 -0
- package/delayed-stream/License +19 -0
- package/delayed-stream/Makefile +7 -0
- package/delayed-stream/Readme.md +141 -0
- package/delayed-stream/lib/delayed_stream.js +107 -0
- package/delayed-stream/package.json +27 -0
- package/ecc-jsbn/LICENSE +21 -0
- package/ecc-jsbn/README.md +8 -0
- package/ecc-jsbn/index.js +58 -0
- package/ecc-jsbn/lib/LICENSE-jsbn +40 -0
- package/ecc-jsbn/lib/ec.js +561 -0
- package/ecc-jsbn/lib/sec.js +170 -0
- package/ecc-jsbn/package.json +40 -0
- package/ecc-jsbn/test.js +14 -0
- package/extend/.editorconfig +20 -0
- package/extend/.eslintrc +17 -0
- package/extend/.jscs.json +175 -0
- package/extend/.travis.yml +230 -0
- package/extend/CHANGELOG.md +83 -0
- package/extend/LICENSE +23 -0
- package/extend/README.md +81 -0
- package/extend/component.json +32 -0
- package/extend/index.js +117 -0
- package/extend/package.json +42 -0
- package/extsprintf/.gitmodules +0 -0
- package/extsprintf/LICENSE +19 -0
- package/extsprintf/Makefile +24 -0
- package/extsprintf/Makefile.targ +285 -0
- package/extsprintf/README.md +46 -0
- package/extsprintf/jsl.node.conf +137 -0
- package/extsprintf/lib/extsprintf.js +183 -0
- package/extsprintf/package.json +14 -0
- package/fast-deep-equal/LICENSE +21 -0
- package/fast-deep-equal/README.md +96 -0
- package/fast-deep-equal/es6/index.d.ts +2 -0
- package/fast-deep-equal/es6/index.js +72 -0
- package/fast-deep-equal/es6/react.d.ts +2 -0
- package/fast-deep-equal/es6/react.js +79 -0
- package/fast-deep-equal/index.d.ts +4 -0
- package/fast-deep-equal/index.js +46 -0
- package/fast-deep-equal/package.json +61 -0
- package/fast-deep-equal/react.d.ts +2 -0
- package/fast-deep-equal/react.js +53 -0
- package/fast-json-stable-stringify/.eslintrc.yml +26 -0
- package/fast-json-stable-stringify/.github/FUNDING.yml +1 -0
- package/fast-json-stable-stringify/.travis.yml +8 -0
- package/fast-json-stable-stringify/LICENSE +21 -0
- package/fast-json-stable-stringify/README.md +131 -0
- package/fast-json-stable-stringify/benchmark/index.js +31 -0
- package/fast-json-stable-stringify/benchmark/test.json +137 -0
- package/fast-json-stable-stringify/example/key_cmp.js +7 -0
- package/fast-json-stable-stringify/example/nested.js +3 -0
- package/fast-json-stable-stringify/example/str.js +3 -0
- package/fast-json-stable-stringify/example/value_cmp.js +7 -0
- package/fast-json-stable-stringify/index.d.ts +4 -0
- package/fast-json-stable-stringify/index.js +59 -0
- package/fast-json-stable-stringify/package.json +52 -0
- package/fast-json-stable-stringify/test/cmp.js +13 -0
- package/fast-json-stable-stringify/test/nested.js +44 -0
- package/fast-json-stable-stringify/test/str.js +46 -0
- package/fast-json-stable-stringify/test/to-json.js +22 -0
- package/follow-redirects/LICENSE +18 -0
- package/follow-redirects/README.md +155 -0
- package/follow-redirects/debug.js +15 -0
- package/follow-redirects/http.js +1 -0
- package/follow-redirects/https.js +1 -0
- package/follow-redirects/index.js +598 -0
- package/follow-redirects/package.json +59 -0
- package/forever-agent/LICENSE +55 -0
- package/forever-agent/README.md +4 -0
- package/forever-agent/index.js +138 -0
- package/forever-agent/package.json +17 -0
- package/form-data/License +19 -0
- package/form-data/README.md +234 -0
- package/form-data/README.md.bak +234 -0
- package/form-data/lib/browser.js +2 -0
- package/form-data/lib/form_data.js +457 -0
- package/form-data/lib/populate.js +10 -0
- package/form-data/package.json +65 -0
- package/form-data/yarn.lock +2662 -0
- package/getpass/.travis.yml +9 -0
- package/getpass/LICENSE +18 -0
- package/getpass/README.md +32 -0
- package/getpass/lib/index.js +123 -0
- package/getpass/package.json +18 -0
- package/har-schema/LICENSE +13 -0
- package/har-schema/README.md +49 -0
- package/har-schema/lib/afterRequest.json +30 -0
- package/har-schema/lib/beforeRequest.json +30 -0
- package/har-schema/lib/browser.json +20 -0
- package/har-schema/lib/cache.json +21 -0
- package/har-schema/lib/content.json +29 -0
- package/har-schema/lib/cookie.json +36 -0
- package/har-schema/lib/creator.json +20 -0
- package/har-schema/lib/entry.json +53 -0
- package/har-schema/lib/har.json +13 -0
- package/har-schema/lib/header.json +20 -0
- package/har-schema/lib/index.js +22 -0
- package/har-schema/lib/log.json +36 -0
- package/har-schema/lib/page.json +32 -0
- package/har-schema/lib/pageTimings.json +18 -0
- package/har-schema/lib/postData.json +43 -0
- package/har-schema/lib/query.json +20 -0
- package/har-schema/lib/request.json +57 -0
- package/har-schema/lib/response.json +54 -0
- package/har-schema/lib/timings.json +42 -0
- package/har-schema/package.json +54 -0
- package/har-validator/LICENSE +9 -0
- package/har-validator/README.md +43 -0
- package/har-validator/lib/async.js +105 -0
- package/har-validator/lib/error.js +17 -0
- package/har-validator/lib/promise.js +102 -0
- package/har-validator/package.json +43 -0
- package/http-signature/.dir-locals.el +6 -0
- package/http-signature/CHANGES.md +46 -0
- package/http-signature/LICENSE +18 -0
- package/http-signature/README.md +79 -0
- package/http-signature/http_signing.md +363 -0
- package/http-signature/lib/index.js +29 -0
- package/http-signature/lib/parser.js +315 -0
- package/http-signature/lib/signer.js +401 -0
- package/http-signature/lib/utils.js +112 -0
- package/http-signature/lib/verify.js +88 -0
- package/http-signature/package.json +39 -0
- package/is-typedarray/LICENSE.md +18 -0
- package/is-typedarray/README.md +16 -0
- package/is-typedarray/index.js +41 -0
- package/is-typedarray/package.json +30 -0
- package/is-typedarray/test.js +34 -0
- package/isstream/.jshintrc +59 -0
- package/isstream/.travis.yml +12 -0
- package/isstream/LICENSE.md +11 -0
- package/isstream/README.md +66 -0
- package/isstream/isstream.js +27 -0
- package/isstream/package.json +33 -0
- package/isstream/test.js +168 -0
- package/jsbn/LICENSE +40 -0
- package/jsbn/README.md +175 -0
- package/jsbn/example.html +12 -0
- package/jsbn/example.js +3 -0
- package/jsbn/index.js +1357 -0
- package/jsbn/package.json +21 -0
- package/json-schema/LICENSE +195 -0
- package/json-schema/README.md +3 -0
- package/json-schema/lib/links.js +65 -0
- package/json-schema/lib/validate.js +271 -0
- package/json-schema/package.json +24 -0
- package/json-schema-traverse/.eslintrc.yml +27 -0
- package/json-schema-traverse/.travis.yml +8 -0
- package/json-schema-traverse/LICENSE +21 -0
- package/json-schema-traverse/README.md +83 -0
- package/json-schema-traverse/index.js +89 -0
- package/json-schema-traverse/package.json +43 -0
- package/json-schema-traverse/spec/.eslintrc.yml +6 -0
- package/json-schema-traverse/spec/fixtures/schema.js +125 -0
- package/json-schema-traverse/spec/index.spec.js +171 -0
- package/json-stringify-safe/CHANGELOG.md +14 -0
- package/json-stringify-safe/LICENSE +15 -0
- package/json-stringify-safe/Makefile +35 -0
- package/json-stringify-safe/README.md +52 -0
- package/json-stringify-safe/package.json +31 -0
- package/json-stringify-safe/stringify.js +27 -0
- package/json-stringify-safe/test/mocha.opts +2 -0
- package/json-stringify-safe/test/stringify_test.js +246 -0
- package/jsprim/CHANGES.md +53 -0
- package/jsprim/CONTRIBUTING.md +19 -0
- package/jsprim/LICENSE +19 -0
- package/jsprim/README.md +287 -0
- package/jsprim/lib/jsprim.js +735 -0
- package/jsprim/package.json +20 -0
- package/m3u8stream/LICENSE +21 -0
- package/m3u8stream/README.md +81 -0
- package/m3u8stream/dist/dash-mpd-parser.d.ts +11 -0
- package/m3u8stream/dist/dash-mpd-parser.js +183 -0
- package/m3u8stream/dist/dash-mpd-parser.js.map +1 -0
- package/m3u8stream/dist/index.d.ts +31 -0
- package/m3u8stream/dist/index.js +180 -0
- package/m3u8stream/dist/index.js.map +1 -0
- package/m3u8stream/dist/m3u8-parser.d.ts +18 -0
- package/m3u8stream/dist/m3u8-parser.js +111 -0
- package/m3u8stream/dist/m3u8-parser.js.map +1 -0
- package/m3u8stream/dist/parse-time.d.ts +16 -0
- package/m3u8stream/dist/parse-time.js +59 -0
- package/m3u8stream/dist/parse-time.js.map +1 -0
- package/m3u8stream/dist/parser.d.ts +19 -0
- package/m3u8stream/dist/parser.js +3 -0
- package/m3u8stream/dist/parser.js.map +1 -0
- package/m3u8stream/dist/queue.d.ts +39 -0
- package/m3u8stream/dist/queue.js +58 -0
- package/m3u8stream/dist/queue.js.map +1 -0
- package/m3u8stream/node_modules/sax/LICENSE +41 -0
- package/m3u8stream/node_modules/sax/README.md +225 -0
- package/m3u8stream/node_modules/sax/lib/sax.js +1565 -0
- package/m3u8stream/node_modules/sax/package.json +25 -0
- package/m3u8stream/package.json +54 -0
- package/mime-db/HISTORY.md +507 -0
- package/mime-db/LICENSE +23 -0
- package/mime-db/README.md +100 -0
- package/mime-db/db.json +8519 -0
- package/mime-db/index.js +12 -0
- package/mime-db/package.json +60 -0
- package/mime-types/HISTORY.md +397 -0
- package/mime-types/LICENSE +23 -0
- package/mime-types/README.md +113 -0
- package/mime-types/index.js +188 -0
- package/mime-types/package.json +44 -0
- package/miniget/LICENSE +21 -0
- package/miniget/README.md +111 -0
- package/miniget/dist/index.d.ts +65 -0
- package/miniget/dist/index.js +281 -0
- package/miniget/dist/index.js.map +1 -0
- package/miniget/package.json +49 -0
- package/oauth-sign/LICENSE +55 -0
- package/oauth-sign/README.md +11 -0
- package/oauth-sign/index.js +146 -0
- package/oauth-sign/package.json +23 -0
- package/package.json +11 -0
- package/performance-now/.tm_properties +7 -0
- package/performance-now/.travis.yml +6 -0
- package/performance-now/README.md +30 -0
- package/performance-now/lib/performance-now.js +36 -0
- package/performance-now/lib/performance-now.js.map +10 -0
- package/performance-now/license.txt +7 -0
- package/performance-now/package.json +35 -0
- package/performance-now/src/index.d.ts +8 -0
- package/performance-now/src/performance-now.coffee +17 -0
- package/performance-now/test/mocha.opts +3 -0
- package/performance-now/test/performance-now.coffee +43 -0
- package/performance-now/test/scripts/delayed-call.coffee +11 -0
- package/performance-now/test/scripts/delayed-require.coffee +12 -0
- package/performance-now/test/scripts/difference.coffee +6 -0
- package/performance-now/test/scripts/initial-value.coffee +10 -0
- package/performance-now/test/scripts.coffee +27 -0
- package/psl/.env +0 -0
- package/psl/LICENSE +9 -0
- package/psl/README.md +211 -0
- package/psl/browserstack-logo.svg +90 -0
- package/psl/data/rules.json +9376 -0
- package/psl/dist/psl.js +10187 -0
- package/psl/dist/psl.min.js +1 -0
- package/psl/index.js +269 -0
- package/psl/package.json +43 -0
- package/punycode/LICENSE-MIT.txt +20 -0
- package/punycode/README.md +122 -0
- package/punycode/package.json +58 -0
- package/punycode/punycode.es6.js +441 -0
- package/punycode/punycode.js +440 -0
- package/qs/.editorconfig +43 -0
- package/qs/.eslintrc +37 -0
- package/qs/.github/FUNDING.yml +12 -0
- package/qs/.nycrc +13 -0
- package/qs/CHANGELOG.md +250 -0
- package/qs/LICENSE.md +29 -0
- package/qs/README.md +510 -0
- package/qs/bower.json +21 -0
- package/qs/component.json +15 -0
- package/qs/dist/qs.js +648 -0
- package/qs/lib/formats.js +18 -0
- package/qs/lib/index.js +11 -0
- package/qs/lib/parse.js +175 -0
- package/qs/lib/stringify.js +217 -0
- package/qs/lib/utils.js +215 -0
- package/qs/package.json +54 -0
- package/qs/test/index.js +7 -0
- package/qs/test/parse.js +649 -0
- package/qs/test/stringify.js +642 -0
- package/qs/test/utils.js +65 -0
- package/request/CHANGELOG.md +717 -0
- package/request/LICENSE +55 -0
- package/request/README.md +1133 -0
- package/request/index.js +155 -0
- package/request/lib/auth.js +167 -0
- package/request/lib/cookies.js +38 -0
- package/request/lib/getProxyFromURI.js +79 -0
- package/request/lib/har.js +205 -0
- package/request/lib/hawk.js +89 -0
- package/request/lib/helpers.js +66 -0
- package/request/lib/multipart.js +112 -0
- package/request/lib/oauth.js +148 -0
- package/request/lib/querystring.js +50 -0
- package/request/lib/redirect.js +154 -0
- package/request/lib/tunnel.js +175 -0
- package/request/package.json +86 -0
- package/request/request.js +1553 -0
- package/safe-buffer/LICENSE +21 -0
- package/safe-buffer/README.md +584 -0
- package/safe-buffer/index.d.ts +187 -0
- package/safe-buffer/index.js +65 -0
- package/safe-buffer/package.json +51 -0
- package/safer-buffer/LICENSE +21 -0
- package/safer-buffer/Porting-Buffer.md +268 -0
- package/safer-buffer/Readme.md +156 -0
- package/safer-buffer/dangerous.js +58 -0
- package/safer-buffer/package.json +34 -0
- package/safer-buffer/safer.js +77 -0
- package/safer-buffer/tests.js +406 -0
- package/sax/AUTHORS +10 -0
- package/sax/LICENSE +32 -0
- package/sax/LICENSE-W3C.html +188 -0
- package/sax/README.md +216 -0
- package/sax/component.json +12 -0
- package/sax/examples/big-not-pretty.xml +8002 -0
- package/sax/examples/example.js +29 -0
- package/sax/examples/get-products.js +58 -0
- package/sax/examples/hello-world.js +4 -0
- package/sax/examples/not-pretty.xml +8 -0
- package/sax/examples/pretty-print.js +74 -0
- package/sax/examples/shopping.xml +2 -0
- package/sax/examples/strict.dtd +870 -0
- package/sax/examples/test.html +15 -0
- package/sax/examples/test.xml +1254 -0
- package/sax/lib/sax.js +1355 -0
- package/sax/package.json +12 -0
- package/sax/test/attribute-name.js +33 -0
- package/sax/test/attribute-no-space.js +75 -0
- package/sax/test/buffer-overrun.js +26 -0
- package/sax/test/case.js +50 -0
- package/sax/test/cdata-chunked.js +11 -0
- package/sax/test/cdata-end-split.js +15 -0
- package/sax/test/cdata-fake-end.js +28 -0
- package/sax/test/cdata-multiple.js +15 -0
- package/sax/test/cdata.js +10 -0
- package/sax/test/cyrillic.js +8 -0
- package/sax/test/duplicate-attribute.js +13 -0
- package/sax/test/end_empty_stream.js +5 -0
- package/sax/test/entities.js +10 -0
- package/sax/test/entity-mega.js +16 -0
- package/sax/test/flush.js +13 -0
- package/sax/test/index.js +86 -0
- package/sax/test/issue-23.js +43 -0
- package/sax/test/issue-30.js +24 -0
- package/sax/test/issue-35.js +15 -0
- package/sax/test/issue-47.js +12 -0
- package/sax/test/issue-49.js +31 -0
- package/sax/test/issue-84.js +13 -0
- package/sax/test/parser-position.js +28 -0
- package/sax/test/script-close-better.js +12 -0
- package/sax/test/script.js +12 -0
- package/sax/test/self-closing-child-strict.js +44 -0
- package/sax/test/self-closing-child.js +44 -0
- package/sax/test/self-closing-tag.js +25 -0
- package/sax/test/stray-ending.js +17 -0
- package/sax/test/trailing-attribute-no-value.js +10 -0
- package/sax/test/trailing-non-whitespace.js +18 -0
- package/sax/test/unclosed-root.js +11 -0
- package/sax/test/unquoted.js +18 -0
- package/sax/test/utf8-split.js +32 -0
- package/sax/test/xmlns-as-tag-name.js +15 -0
- package/sax/test/xmlns-issue-41.js +68 -0
- package/sax/test/xmlns-rebinding.js +63 -0
- package/sax/test/xmlns-strict.js +74 -0
- package/sax/test/xmlns-unbound-element.js +33 -0
- package/sax/test/xmlns-unbound.js +15 -0
- package/sax/test/xmlns-xml-default-ns.js +31 -0
- package/sax/test/xmlns-xml-default-prefix-attribute.js +36 -0
- package/sax/test/xmlns-xml-default-prefix.js +21 -0
- package/sax/test/xmlns-xml-default-redefine.js +41 -0
- package/simple-csv-reader/.editorconfig +8 -0
- package/simple-csv-reader/LICENSE +21 -0
- package/simple-csv-reader/README.md +32 -0
- package/simple-csv-reader/dist/simple-csv-reader.min.js +2 -0
- package/simple-csv-reader/dist/simple-csv-reader.min.js.map +1 -0
- package/simple-csv-reader/gulpfile.js +26 -0
- package/simple-csv-reader/index.js +131 -0
- package/simple-csv-reader/package.json +38 -0
- package/sshpk/.travis.yml +11 -0
- package/sshpk/Jenkinsfile +86 -0
- package/sshpk/LICENSE +18 -0
- package/sshpk/README.md +804 -0
- package/sshpk/bin/sshpk-conv +243 -0
- package/sshpk/bin/sshpk-sign +191 -0
- package/sshpk/bin/sshpk-verify +167 -0
- package/sshpk/lib/algs.js +168 -0
- package/sshpk/lib/certificate.js +410 -0
- package/sshpk/lib/dhe.js +397 -0
- package/sshpk/lib/ed-compat.js +92 -0
- package/sshpk/lib/errors.js +84 -0
- package/sshpk/lib/fingerprint.js +220 -0
- package/sshpk/lib/formats/auto.js +124 -0
- package/sshpk/lib/formats/dnssec.js +287 -0
- package/sshpk/lib/formats/openssh-cert.js +352 -0
- package/sshpk/lib/formats/pem.js +290 -0
- package/sshpk/lib/formats/pkcs1.js +373 -0
- package/sshpk/lib/formats/pkcs8.js +631 -0
- package/sshpk/lib/formats/putty.js +194 -0
- package/sshpk/lib/formats/rfc4253.js +166 -0
- package/sshpk/lib/formats/ssh-private.js +262 -0
- package/sshpk/lib/formats/ssh.js +115 -0
- package/sshpk/lib/formats/x509-pem.js +88 -0
- package/sshpk/lib/formats/x509.js +752 -0
- package/sshpk/lib/identity.js +373 -0
- package/sshpk/lib/index.js +40 -0
- package/sshpk/lib/key.js +294 -0
- package/sshpk/lib/private-key.js +247 -0
- package/sshpk/lib/signature.js +314 -0
- package/sshpk/lib/ssh-buffer.js +149 -0
- package/sshpk/lib/utils.js +404 -0
- package/sshpk/man/man1/sshpk-conv.1 +135 -0
- package/sshpk/man/man1/sshpk-sign.1 +81 -0
- package/sshpk/man/man1/sshpk-verify.1 +68 -0
- package/sshpk/package.json +60 -0
- package/tough-cookie/LICENSE +12 -0
- package/tough-cookie/README.md +527 -0
- package/tough-cookie/lib/cookie.js +1482 -0
- package/tough-cookie/lib/memstore.js +181 -0
- package/tough-cookie/lib/pathMatch.js +61 -0
- package/tough-cookie/lib/permuteDomain.js +56 -0
- package/tough-cookie/lib/pubsuffix-psl.js +38 -0
- package/tough-cookie/lib/store.js +75 -0
- package/tough-cookie/lib/version.js +2 -0
- package/tough-cookie/package.json +78 -0
- package/tunnel-agent/LICENSE +55 -0
- package/tunnel-agent/README.md +4 -0
- package/tunnel-agent/index.js +244 -0
- package/tunnel-agent/package.json +22 -0
- package/tweetnacl/AUTHORS.md +28 -0
- package/tweetnacl/CHANGELOG.md +221 -0
- package/tweetnacl/LICENSE +24 -0
- package/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
- package/tweetnacl/README.md +459 -0
- package/tweetnacl/nacl-fast.js +2388 -0
- package/tweetnacl/nacl-fast.min.js +2 -0
- package/tweetnacl/nacl.d.ts +98 -0
- package/tweetnacl/nacl.js +1175 -0
- package/tweetnacl/nacl.min.js +1 -0
- package/tweetnacl/package.json +58 -0
- package/uri-js/LICENSE +11 -0
- package/uri-js/README.md +203 -0
- package/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/uri-js/dist/es5/uri.all.js +1443 -0
- package/uri-js/dist/es5/uri.all.js.map +1 -0
- package/uri-js/dist/es5/uri.all.min.d.ts +59 -0
- package/uri-js/dist/es5/uri.all.min.js +3 -0
- package/uri-js/dist/es5/uri.all.min.js.map +1 -0
- package/uri-js/dist/esnext/index.d.ts +1 -0
- package/uri-js/dist/esnext/index.js +17 -0
- package/uri-js/dist/esnext/index.js.map +1 -0
- package/uri-js/dist/esnext/regexps-iri.d.ts +3 -0
- package/uri-js/dist/esnext/regexps-iri.js +3 -0
- package/uri-js/dist/esnext/regexps-iri.js.map +1 -0
- package/uri-js/dist/esnext/regexps-uri.d.ts +4 -0
- package/uri-js/dist/esnext/regexps-uri.js +42 -0
- package/uri-js/dist/esnext/regexps-uri.js.map +1 -0
- package/uri-js/dist/esnext/schemes/http.d.ts +3 -0
- package/uri-js/dist/esnext/schemes/http.js +28 -0
- package/uri-js/dist/esnext/schemes/http.js.map +1 -0
- package/uri-js/dist/esnext/schemes/https.d.ts +3 -0
- package/uri-js/dist/esnext/schemes/https.js +9 -0
- package/uri-js/dist/esnext/schemes/https.js.map +1 -0
- package/uri-js/dist/esnext/schemes/mailto.d.ts +12 -0
- package/uri-js/dist/esnext/schemes/mailto.js +148 -0
- package/uri-js/dist/esnext/schemes/mailto.js.map +1 -0
- package/uri-js/dist/esnext/schemes/urn-uuid.d.ts +7 -0
- package/uri-js/dist/esnext/schemes/urn-uuid.js +23 -0
- package/uri-js/dist/esnext/schemes/urn-uuid.js.map +1 -0
- package/uri-js/dist/esnext/schemes/urn.d.ts +10 -0
- package/uri-js/dist/esnext/schemes/urn.js +49 -0
- package/uri-js/dist/esnext/schemes/urn.js.map +1 -0
- package/uri-js/dist/esnext/schemes/ws.d.ts +7 -0
- package/uri-js/dist/esnext/schemes/ws.js +41 -0
- package/uri-js/dist/esnext/schemes/ws.js.map +1 -0
- package/uri-js/dist/esnext/schemes/wss.d.ts +3 -0
- package/uri-js/dist/esnext/schemes/wss.js +9 -0
- package/uri-js/dist/esnext/schemes/wss.js.map +1 -0
- package/uri-js/dist/esnext/uri.d.ts +59 -0
- package/uri-js/dist/esnext/uri.js +480 -0
- package/uri-js/dist/esnext/uri.js.map +1 -0
- package/uri-js/dist/esnext/util.d.ts +6 -0
- package/uri-js/dist/esnext/util.js +36 -0
- package/uri-js/dist/esnext/util.js.map +1 -0
- package/uri-js/package.json +77 -0
- package/uri-js/yarn.lock +2558 -0
- package/uuid/AUTHORS +5 -0
- package/uuid/CHANGELOG.md +119 -0
- package/uuid/LICENSE.md +21 -0
- package/uuid/README.md +276 -0
- package/uuid/bin/uuid +65 -0
- package/uuid/index.js +8 -0
- package/uuid/lib/bytesToUuid.js +26 -0
- package/uuid/lib/md5-browser.js +216 -0
- package/uuid/lib/md5.js +25 -0
- package/uuid/lib/rng-browser.js +34 -0
- package/uuid/lib/rng.js +8 -0
- package/uuid/lib/sha1-browser.js +89 -0
- package/uuid/lib/sha1.js +25 -0
- package/uuid/lib/v35.js +57 -0
- package/uuid/package.json +49 -0
- package/uuid/v1.js +109 -0
- package/uuid/v3.js +4 -0
- package/uuid/v4.js +29 -0
- package/uuid/v5.js +3 -0
- package/verror/CHANGES.md +28 -0
- package/verror/CONTRIBUTING.md +19 -0
- package/verror/LICENSE +19 -0
- package/verror/README.md +528 -0
- package/verror/lib/verror.js +451 -0
- package/verror/package.json +22 -0
- package/xml2js/.travis.yml +5 -0
- package/xml2js/83.coffee +6 -0
- package/xml2js/LICENSE +19 -0
- package/xml2js/README.md +248 -0
- package/xml2js/canon.xml +482 -0
- package/xml2js/lib/xml2js.js +299 -0
- package/xml2js/package.json +47 -0
- package/xml2js/text.coffee +11 -0
- package/xml2js/text.xml +485 -0
- package/youtube-search/.travis.yml +5 -0
- package/youtube-search/README.md +61 -0
- package/youtube-search/index.d.ts +77 -0
- package/youtube-search/index.js +111 -0
- package/youtube-search/package.json +29 -0
- package/youtube-search/tests/test-search.js +32 -0
- package/ytdl-core/LICENSE +21 -0
- package/ytdl-core/README.md +238 -0
- package/ytdl-core/lib/cache.js +54 -0
- package/ytdl-core/lib/format-utils.js +250 -0
- package/ytdl-core/lib/formats.js +524 -0
- package/ytdl-core/lib/index.js +214 -0
- package/ytdl-core/lib/info-extras.js +365 -0
- package/ytdl-core/lib/info.js +495 -0
- package/ytdl-core/lib/sig.js +122 -0
- package/ytdl-core/lib/url-utils.js +91 -0
- package/ytdl-core/lib/utils.js +286 -0
- package/ytdl-core/node_modules/sax/LICENSE +41 -0
- package/ytdl-core/node_modules/sax/README.md +225 -0
- package/ytdl-core/node_modules/sax/lib/sax.js +1565 -0
- package/ytdl-core/node_modules/sax/package.json +25 -0
- package/ytdl-core/package.json +61 -0
- package/ytdl-core/typings/index.d.ts +426 -0
- package/ytdl-getinfo/.travis.yml +3 -0
- package/ytdl-getinfo/README.md +77 -0
- package/ytdl-getinfo/index.js +105 -0
- package/ytdl-getinfo/package.json +33 -0
- package/ytdl-getinfo/playlist.js +50 -0
- package/ytdl-getinfo/test/test.js +68 -0
- package/ytdl-getinfo/updater.js +42 -0
- package/ytdl-getinfo/yarn.lock +533 -0
- package/ytdl-getinfo/ytdl/.gitkeep +0 -0
- package/ytdl-getinfo/ytdl/youtube-dl.exe +0 -0
package/sax/lib/sax.js
ADDED
@@ -0,0 +1,1355 @@
|
|
1
|
+
// wrapper for non-node envs
|
2
|
+
;(function (sax) {
|
3
|
+
|
4
|
+
sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
|
5
|
+
sax.SAXParser = SAXParser
|
6
|
+
sax.SAXStream = SAXStream
|
7
|
+
sax.createStream = createStream
|
8
|
+
|
9
|
+
// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
|
10
|
+
// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
|
11
|
+
// since that's the earliest that a buffer overrun could occur. This way, checks are
|
12
|
+
// as rare as required, but as often as necessary to ensure never crossing this bound.
|
13
|
+
// Furthermore, buffers are only tested at most once per write(), so passing a very
|
14
|
+
// large string into write() might have undesirable effects, but this is manageable by
|
15
|
+
// the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
|
16
|
+
// edge case, result in creating at most one complete copy of the string passed in.
|
17
|
+
// Set to Infinity to have unlimited buffers.
|
18
|
+
sax.MAX_BUFFER_LENGTH = 64 * 1024
|
19
|
+
|
20
|
+
var buffers = [
|
21
|
+
"comment", "sgmlDecl", "textNode", "tagName", "doctype",
|
22
|
+
"procInstName", "procInstBody", "entity", "attribName",
|
23
|
+
"attribValue", "cdata", "script"
|
24
|
+
]
|
25
|
+
|
26
|
+
sax.EVENTS = // for discoverability.
|
27
|
+
[ "text"
|
28
|
+
, "processinginstruction"
|
29
|
+
, "sgmldeclaration"
|
30
|
+
, "doctype"
|
31
|
+
, "comment"
|
32
|
+
, "attribute"
|
33
|
+
, "opentag"
|
34
|
+
, "closetag"
|
35
|
+
, "opencdata"
|
36
|
+
, "cdata"
|
37
|
+
, "closecdata"
|
38
|
+
, "error"
|
39
|
+
, "end"
|
40
|
+
, "ready"
|
41
|
+
, "script"
|
42
|
+
, "opennamespace"
|
43
|
+
, "closenamespace"
|
44
|
+
]
|
45
|
+
|
46
|
+
function SAXParser (strict, opt) {
|
47
|
+
if (!(this instanceof SAXParser)) return new SAXParser(strict, opt)
|
48
|
+
|
49
|
+
var parser = this
|
50
|
+
clearBuffers(parser)
|
51
|
+
parser.q = parser.c = ""
|
52
|
+
parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
|
53
|
+
parser.opt = opt || {}
|
54
|
+
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
|
55
|
+
parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase"
|
56
|
+
parser.tags = []
|
57
|
+
parser.closed = parser.closedRoot = parser.sawRoot = false
|
58
|
+
parser.tag = parser.error = null
|
59
|
+
parser.strict = !!strict
|
60
|
+
parser.noscript = !!(strict || parser.opt.noscript)
|
61
|
+
parser.state = S.BEGIN
|
62
|
+
parser.ENTITIES = Object.create(sax.ENTITIES)
|
63
|
+
parser.attribList = []
|
64
|
+
|
65
|
+
// namespaces form a prototype chain.
|
66
|
+
// it always points at the current tag,
|
67
|
+
// which protos to its parent tag.
|
68
|
+
if (parser.opt.xmlns) parser.ns = Object.create(rootNS)
|
69
|
+
|
70
|
+
// mostly just for error reporting
|
71
|
+
parser.trackPosition = parser.opt.position !== false
|
72
|
+
if (parser.trackPosition) {
|
73
|
+
parser.position = parser.line = parser.column = 0
|
74
|
+
}
|
75
|
+
emit(parser, "onready")
|
76
|
+
}
|
77
|
+
|
78
|
+
if (!Object.create) Object.create = function (o) {
|
79
|
+
function f () { this.__proto__ = o }
|
80
|
+
f.prototype = o
|
81
|
+
return new f
|
82
|
+
}
|
83
|
+
|
84
|
+
if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) {
|
85
|
+
return o.__proto__
|
86
|
+
}
|
87
|
+
|
88
|
+
if (!Object.keys) Object.keys = function (o) {
|
89
|
+
var a = []
|
90
|
+
for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
|
91
|
+
return a
|
92
|
+
}
|
93
|
+
|
94
|
+
function checkBufferLength (parser) {
|
95
|
+
var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
|
96
|
+
, maxActual = 0
|
97
|
+
for (var i = 0, l = buffers.length; i < l; i ++) {
|
98
|
+
var len = parser[buffers[i]].length
|
99
|
+
if (len > maxAllowed) {
|
100
|
+
// Text/cdata nodes can get big, and since they're buffered,
|
101
|
+
// we can get here under normal conditions.
|
102
|
+
// Avoid issues by emitting the text node now,
|
103
|
+
// so at least it won't get any bigger.
|
104
|
+
switch (buffers[i]) {
|
105
|
+
case "textNode":
|
106
|
+
closeText(parser)
|
107
|
+
break
|
108
|
+
|
109
|
+
case "cdata":
|
110
|
+
emitNode(parser, "oncdata", parser.cdata)
|
111
|
+
parser.cdata = ""
|
112
|
+
break
|
113
|
+
|
114
|
+
case "script":
|
115
|
+
emitNode(parser, "onscript", parser.script)
|
116
|
+
parser.script = ""
|
117
|
+
break
|
118
|
+
|
119
|
+
default:
|
120
|
+
error(parser, "Max buffer length exceeded: "+buffers[i])
|
121
|
+
}
|
122
|
+
}
|
123
|
+
maxActual = Math.max(maxActual, len)
|
124
|
+
}
|
125
|
+
// schedule the next check for the earliest possible buffer overrun.
|
126
|
+
parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual)
|
127
|
+
+ parser.position
|
128
|
+
}
|
129
|
+
|
130
|
+
function clearBuffers (parser) {
|
131
|
+
for (var i = 0, l = buffers.length; i < l; i ++) {
|
132
|
+
parser[buffers[i]] = ""
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
function flushBuffers (parser) {
|
137
|
+
closeText(parser)
|
138
|
+
if (parser.cdata !== "") {
|
139
|
+
emitNode(parser, "oncdata", parser.cdata)
|
140
|
+
parser.cdata = ""
|
141
|
+
}
|
142
|
+
if (parser.script !== "") {
|
143
|
+
emitNode(parser, "onscript", parser.script)
|
144
|
+
parser.script = ""
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
SAXParser.prototype =
|
149
|
+
{ end: function () { end(this) }
|
150
|
+
, write: write
|
151
|
+
, resume: function () { this.error = null; return this }
|
152
|
+
, close: function () { return this.write(null) }
|
153
|
+
, flush: function () { flushBuffers(this) }
|
154
|
+
}
|
155
|
+
|
156
|
+
try {
|
157
|
+
var Stream = require("stream").Stream
|
158
|
+
} catch (ex) {
|
159
|
+
var Stream = function () {}
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
var streamWraps = sax.EVENTS.filter(function (ev) {
|
164
|
+
return ev !== "error" && ev !== "end"
|
165
|
+
})
|
166
|
+
|
167
|
+
function createStream (strict, opt) {
|
168
|
+
return new SAXStream(strict, opt)
|
169
|
+
}
|
170
|
+
|
171
|
+
function SAXStream (strict, opt) {
|
172
|
+
if (!(this instanceof SAXStream)) return new SAXStream(strict, opt)
|
173
|
+
|
174
|
+
Stream.apply(this)
|
175
|
+
|
176
|
+
this._parser = new SAXParser(strict, opt)
|
177
|
+
this.writable = true
|
178
|
+
this.readable = true
|
179
|
+
|
180
|
+
|
181
|
+
var me = this
|
182
|
+
|
183
|
+
this._parser.onend = function () {
|
184
|
+
me.emit("end")
|
185
|
+
}
|
186
|
+
|
187
|
+
this._parser.onerror = function (er) {
|
188
|
+
me.emit("error", er)
|
189
|
+
|
190
|
+
// if didn't throw, then means error was handled.
|
191
|
+
// go ahead and clear error, so we can write again.
|
192
|
+
me._parser.error = null
|
193
|
+
}
|
194
|
+
|
195
|
+
this._decoder = null;
|
196
|
+
|
197
|
+
streamWraps.forEach(function (ev) {
|
198
|
+
Object.defineProperty(me, "on" + ev, {
|
199
|
+
get: function () { return me._parser["on" + ev] },
|
200
|
+
set: function (h) {
|
201
|
+
if (!h) {
|
202
|
+
me.removeAllListeners(ev)
|
203
|
+
return me._parser["on"+ev] = h
|
204
|
+
}
|
205
|
+
me.on(ev, h)
|
206
|
+
},
|
207
|
+
enumerable: true,
|
208
|
+
configurable: false
|
209
|
+
})
|
210
|
+
})
|
211
|
+
}
|
212
|
+
|
213
|
+
SAXStream.prototype = Object.create(Stream.prototype,
|
214
|
+
{ constructor: { value: SAXStream } })
|
215
|
+
|
216
|
+
SAXStream.prototype.write = function (data) {
|
217
|
+
if (typeof Buffer === 'function' &&
|
218
|
+
typeof Buffer.isBuffer === 'function' &&
|
219
|
+
Buffer.isBuffer(data)) {
|
220
|
+
if (!this._decoder) {
|
221
|
+
var SD = require('string_decoder').StringDecoder
|
222
|
+
this._decoder = new SD('utf8')
|
223
|
+
}
|
224
|
+
data = this._decoder.write(data);
|
225
|
+
}
|
226
|
+
|
227
|
+
this._parser.write(data.toString())
|
228
|
+
this.emit("data", data)
|
229
|
+
return true
|
230
|
+
}
|
231
|
+
|
232
|
+
SAXStream.prototype.end = function (chunk) {
|
233
|
+
if (chunk && chunk.length) this.write(chunk)
|
234
|
+
this._parser.end()
|
235
|
+
return true
|
236
|
+
}
|
237
|
+
|
238
|
+
SAXStream.prototype.on = function (ev, handler) {
|
239
|
+
var me = this
|
240
|
+
if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) {
|
241
|
+
me._parser["on"+ev] = function () {
|
242
|
+
var args = arguments.length === 1 ? [arguments[0]]
|
243
|
+
: Array.apply(null, arguments)
|
244
|
+
args.splice(0, 0, ev)
|
245
|
+
me.emit.apply(me, args)
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
return Stream.prototype.on.call(me, ev, handler)
|
250
|
+
}
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
// character classes and tokens
|
255
|
+
var whitespace = "\r\n\t "
|
256
|
+
// this really needs to be replaced with character classes.
|
257
|
+
// XML allows all manner of ridiculous numbers and digits.
|
258
|
+
, number = "0124356789"
|
259
|
+
, letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
260
|
+
// (Letter | "_" | ":")
|
261
|
+
, quote = "'\""
|
262
|
+
, entity = number+letter+"#"
|
263
|
+
, attribEnd = whitespace + ">"
|
264
|
+
, CDATA = "[CDATA["
|
265
|
+
, DOCTYPE = "DOCTYPE"
|
266
|
+
, XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
|
267
|
+
, XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"
|
268
|
+
, rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
|
269
|
+
|
270
|
+
// turn all the string character sets into character class objects.
|
271
|
+
whitespace = charClass(whitespace)
|
272
|
+
number = charClass(number)
|
273
|
+
letter = charClass(letter)
|
274
|
+
|
275
|
+
// http://www.w3.org/TR/REC-xml/#NT-NameStartChar
|
276
|
+
// This implementation works on strings, a single character at a time
|
277
|
+
// as such, it cannot ever support astral-plane characters (10000-EFFFF)
|
278
|
+
// without a significant breaking change to either this parser, or the
|
279
|
+
// JavaScript language. Implementation of an emoji-capable xml parser
|
280
|
+
// is left as an exercise for the reader.
|
281
|
+
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]/
|
282
|
+
|
283
|
+
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-]/
|
284
|
+
|
285
|
+
quote = charClass(quote)
|
286
|
+
entity = charClass(entity)
|
287
|
+
attribEnd = charClass(attribEnd)
|
288
|
+
|
289
|
+
function charClass (str) {
|
290
|
+
return str.split("").reduce(function (s, c) {
|
291
|
+
s[c] = true
|
292
|
+
return s
|
293
|
+
}, {})
|
294
|
+
}
|
295
|
+
|
296
|
+
function isRegExp (c) {
|
297
|
+
return Object.prototype.toString.call(c) === '[object RegExp]'
|
298
|
+
}
|
299
|
+
|
300
|
+
function is (charclass, c) {
|
301
|
+
return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
|
302
|
+
}
|
303
|
+
|
304
|
+
function not (charclass, c) {
|
305
|
+
return !is(charclass, c)
|
306
|
+
}
|
307
|
+
|
308
|
+
var S = 0
|
309
|
+
sax.STATE =
|
310
|
+
{ BEGIN : S++
|
311
|
+
, TEXT : S++ // general stuff
|
312
|
+
, TEXT_ENTITY : S++ // & and such.
|
313
|
+
, OPEN_WAKA : S++ // <
|
314
|
+
, SGML_DECL : S++ // <!BLARG
|
315
|
+
, SGML_DECL_QUOTED : S++ // <!BLARG foo "bar
|
316
|
+
, DOCTYPE : S++ // <!DOCTYPE
|
317
|
+
, DOCTYPE_QUOTED : S++ // <!DOCTYPE "//blah
|
318
|
+
, DOCTYPE_DTD : S++ // <!DOCTYPE "//blah" [ ...
|
319
|
+
, DOCTYPE_DTD_QUOTED : S++ // <!DOCTYPE "//blah" [ "foo
|
320
|
+
, COMMENT_STARTING : S++ // <!-
|
321
|
+
, COMMENT : S++ // <!--
|
322
|
+
, COMMENT_ENDING : S++ // <!-- blah -
|
323
|
+
, COMMENT_ENDED : S++ // <!-- blah --
|
324
|
+
, CDATA : S++ // <![CDATA[ something
|
325
|
+
, CDATA_ENDING : S++ // ]
|
326
|
+
, CDATA_ENDING_2 : S++ // ]]
|
327
|
+
, PROC_INST : S++ // <?hi
|
328
|
+
, PROC_INST_BODY : S++ // <?hi there
|
329
|
+
, PROC_INST_ENDING : S++ // <?hi "there" ?
|
330
|
+
, OPEN_TAG : S++ // <strong
|
331
|
+
, OPEN_TAG_SLASH : S++ // <strong /
|
332
|
+
, ATTRIB : S++ // <a
|
333
|
+
, ATTRIB_NAME : S++ // <a foo
|
334
|
+
, ATTRIB_NAME_SAW_WHITE : S++ // <a foo _
|
335
|
+
, ATTRIB_VALUE : S++ // <a foo=
|
336
|
+
, ATTRIB_VALUE_QUOTED : S++ // <a foo="bar
|
337
|
+
, ATTRIB_VALUE_CLOSED : S++ // <a foo="bar"
|
338
|
+
, ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar
|
339
|
+
, ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar="""
|
340
|
+
, ATTRIB_VALUE_ENTITY_U : S++ // <foo bar="
|
341
|
+
, CLOSE_TAG : S++ // </a
|
342
|
+
, CLOSE_TAG_SAW_WHITE : S++ // </a >
|
343
|
+
, SCRIPT : S++ // <script> ...
|
344
|
+
, SCRIPT_ENDING : S++ // <script> ... <
|
345
|
+
}
|
346
|
+
|
347
|
+
sax.ENTITIES =
|
348
|
+
{ "amp" : "&"
|
349
|
+
, "gt" : ">"
|
350
|
+
, "lt" : "<"
|
351
|
+
, "quot" : "\""
|
352
|
+
, "apos" : "'"
|
353
|
+
, "AElig" : 198
|
354
|
+
, "Aacute" : 193
|
355
|
+
, "Acirc" : 194
|
356
|
+
, "Agrave" : 192
|
357
|
+
, "Aring" : 197
|
358
|
+
, "Atilde" : 195
|
359
|
+
, "Auml" : 196
|
360
|
+
, "Ccedil" : 199
|
361
|
+
, "ETH" : 208
|
362
|
+
, "Eacute" : 201
|
363
|
+
, "Ecirc" : 202
|
364
|
+
, "Egrave" : 200
|
365
|
+
, "Euml" : 203
|
366
|
+
, "Iacute" : 205
|
367
|
+
, "Icirc" : 206
|
368
|
+
, "Igrave" : 204
|
369
|
+
, "Iuml" : 207
|
370
|
+
, "Ntilde" : 209
|
371
|
+
, "Oacute" : 211
|
372
|
+
, "Ocirc" : 212
|
373
|
+
, "Ograve" : 210
|
374
|
+
, "Oslash" : 216
|
375
|
+
, "Otilde" : 213
|
376
|
+
, "Ouml" : 214
|
377
|
+
, "THORN" : 222
|
378
|
+
, "Uacute" : 218
|
379
|
+
, "Ucirc" : 219
|
380
|
+
, "Ugrave" : 217
|
381
|
+
, "Uuml" : 220
|
382
|
+
, "Yacute" : 221
|
383
|
+
, "aacute" : 225
|
384
|
+
, "acirc" : 226
|
385
|
+
, "aelig" : 230
|
386
|
+
, "agrave" : 224
|
387
|
+
, "aring" : 229
|
388
|
+
, "atilde" : 227
|
389
|
+
, "auml" : 228
|
390
|
+
, "ccedil" : 231
|
391
|
+
, "eacute" : 233
|
392
|
+
, "ecirc" : 234
|
393
|
+
, "egrave" : 232
|
394
|
+
, "eth" : 240
|
395
|
+
, "euml" : 235
|
396
|
+
, "iacute" : 237
|
397
|
+
, "icirc" : 238
|
398
|
+
, "igrave" : 236
|
399
|
+
, "iuml" : 239
|
400
|
+
, "ntilde" : 241
|
401
|
+
, "oacute" : 243
|
402
|
+
, "ocirc" : 244
|
403
|
+
, "ograve" : 242
|
404
|
+
, "oslash" : 248
|
405
|
+
, "otilde" : 245
|
406
|
+
, "ouml" : 246
|
407
|
+
, "szlig" : 223
|
408
|
+
, "thorn" : 254
|
409
|
+
, "uacute" : 250
|
410
|
+
, "ucirc" : 251
|
411
|
+
, "ugrave" : 249
|
412
|
+
, "uuml" : 252
|
413
|
+
, "yacute" : 253
|
414
|
+
, "yuml" : 255
|
415
|
+
, "copy" : 169
|
416
|
+
, "reg" : 174
|
417
|
+
, "nbsp" : 160
|
418
|
+
, "iexcl" : 161
|
419
|
+
, "cent" : 162
|
420
|
+
, "pound" : 163
|
421
|
+
, "curren" : 164
|
422
|
+
, "yen" : 165
|
423
|
+
, "brvbar" : 166
|
424
|
+
, "sect" : 167
|
425
|
+
, "uml" : 168
|
426
|
+
, "ordf" : 170
|
427
|
+
, "laquo" : 171
|
428
|
+
, "not" : 172
|
429
|
+
, "shy" : 173
|
430
|
+
, "macr" : 175
|
431
|
+
, "deg" : 176
|
432
|
+
, "plusmn" : 177
|
433
|
+
, "sup1" : 185
|
434
|
+
, "sup2" : 178
|
435
|
+
, "sup3" : 179
|
436
|
+
, "acute" : 180
|
437
|
+
, "micro" : 181
|
438
|
+
, "para" : 182
|
439
|
+
, "middot" : 183
|
440
|
+
, "cedil" : 184
|
441
|
+
, "ordm" : 186
|
442
|
+
, "raquo" : 187
|
443
|
+
, "frac14" : 188
|
444
|
+
, "frac12" : 189
|
445
|
+
, "frac34" : 190
|
446
|
+
, "iquest" : 191
|
447
|
+
, "times" : 215
|
448
|
+
, "divide" : 247
|
449
|
+
, "OElig" : 338
|
450
|
+
, "oelig" : 339
|
451
|
+
, "Scaron" : 352
|
452
|
+
, "scaron" : 353
|
453
|
+
, "Yuml" : 376
|
454
|
+
, "fnof" : 402
|
455
|
+
, "circ" : 710
|
456
|
+
, "tilde" : 732
|
457
|
+
, "Alpha" : 913
|
458
|
+
, "Beta" : 914
|
459
|
+
, "Gamma" : 915
|
460
|
+
, "Delta" : 916
|
461
|
+
, "Epsilon" : 917
|
462
|
+
, "Zeta" : 918
|
463
|
+
, "Eta" : 919
|
464
|
+
, "Theta" : 920
|
465
|
+
, "Iota" : 921
|
466
|
+
, "Kappa" : 922
|
467
|
+
, "Lambda" : 923
|
468
|
+
, "Mu" : 924
|
469
|
+
, "Nu" : 925
|
470
|
+
, "Xi" : 926
|
471
|
+
, "Omicron" : 927
|
472
|
+
, "Pi" : 928
|
473
|
+
, "Rho" : 929
|
474
|
+
, "Sigma" : 931
|
475
|
+
, "Tau" : 932
|
476
|
+
, "Upsilon" : 933
|
477
|
+
, "Phi" : 934
|
478
|
+
, "Chi" : 935
|
479
|
+
, "Psi" : 936
|
480
|
+
, "Omega" : 937
|
481
|
+
, "alpha" : 945
|
482
|
+
, "beta" : 946
|
483
|
+
, "gamma" : 947
|
484
|
+
, "delta" : 948
|
485
|
+
, "epsilon" : 949
|
486
|
+
, "zeta" : 950
|
487
|
+
, "eta" : 951
|
488
|
+
, "theta" : 952
|
489
|
+
, "iota" : 953
|
490
|
+
, "kappa" : 954
|
491
|
+
, "lambda" : 955
|
492
|
+
, "mu" : 956
|
493
|
+
, "nu" : 957
|
494
|
+
, "xi" : 958
|
495
|
+
, "omicron" : 959
|
496
|
+
, "pi" : 960
|
497
|
+
, "rho" : 961
|
498
|
+
, "sigmaf" : 962
|
499
|
+
, "sigma" : 963
|
500
|
+
, "tau" : 964
|
501
|
+
, "upsilon" : 965
|
502
|
+
, "phi" : 966
|
503
|
+
, "chi" : 967
|
504
|
+
, "psi" : 968
|
505
|
+
, "omega" : 969
|
506
|
+
, "thetasym" : 977
|
507
|
+
, "upsih" : 978
|
508
|
+
, "piv" : 982
|
509
|
+
, "ensp" : 8194
|
510
|
+
, "emsp" : 8195
|
511
|
+
, "thinsp" : 8201
|
512
|
+
, "zwnj" : 8204
|
513
|
+
, "zwj" : 8205
|
514
|
+
, "lrm" : 8206
|
515
|
+
, "rlm" : 8207
|
516
|
+
, "ndash" : 8211
|
517
|
+
, "mdash" : 8212
|
518
|
+
, "lsquo" : 8216
|
519
|
+
, "rsquo" : 8217
|
520
|
+
, "sbquo" : 8218
|
521
|
+
, "ldquo" : 8220
|
522
|
+
, "rdquo" : 8221
|
523
|
+
, "bdquo" : 8222
|
524
|
+
, "dagger" : 8224
|
525
|
+
, "Dagger" : 8225
|
526
|
+
, "bull" : 8226
|
527
|
+
, "hellip" : 8230
|
528
|
+
, "permil" : 8240
|
529
|
+
, "prime" : 8242
|
530
|
+
, "Prime" : 8243
|
531
|
+
, "lsaquo" : 8249
|
532
|
+
, "rsaquo" : 8250
|
533
|
+
, "oline" : 8254
|
534
|
+
, "frasl" : 8260
|
535
|
+
, "euro" : 8364
|
536
|
+
, "image" : 8465
|
537
|
+
, "weierp" : 8472
|
538
|
+
, "real" : 8476
|
539
|
+
, "trade" : 8482
|
540
|
+
, "alefsym" : 8501
|
541
|
+
, "larr" : 8592
|
542
|
+
, "uarr" : 8593
|
543
|
+
, "rarr" : 8594
|
544
|
+
, "darr" : 8595
|
545
|
+
, "harr" : 8596
|
546
|
+
, "crarr" : 8629
|
547
|
+
, "lArr" : 8656
|
548
|
+
, "uArr" : 8657
|
549
|
+
, "rArr" : 8658
|
550
|
+
, "dArr" : 8659
|
551
|
+
, "hArr" : 8660
|
552
|
+
, "forall" : 8704
|
553
|
+
, "part" : 8706
|
554
|
+
, "exist" : 8707
|
555
|
+
, "empty" : 8709
|
556
|
+
, "nabla" : 8711
|
557
|
+
, "isin" : 8712
|
558
|
+
, "notin" : 8713
|
559
|
+
, "ni" : 8715
|
560
|
+
, "prod" : 8719
|
561
|
+
, "sum" : 8721
|
562
|
+
, "minus" : 8722
|
563
|
+
, "lowast" : 8727
|
564
|
+
, "radic" : 8730
|
565
|
+
, "prop" : 8733
|
566
|
+
, "infin" : 8734
|
567
|
+
, "ang" : 8736
|
568
|
+
, "and" : 8743
|
569
|
+
, "or" : 8744
|
570
|
+
, "cap" : 8745
|
571
|
+
, "cup" : 8746
|
572
|
+
, "int" : 8747
|
573
|
+
, "there4" : 8756
|
574
|
+
, "sim" : 8764
|
575
|
+
, "cong" : 8773
|
576
|
+
, "asymp" : 8776
|
577
|
+
, "ne" : 8800
|
578
|
+
, "equiv" : 8801
|
579
|
+
, "le" : 8804
|
580
|
+
, "ge" : 8805
|
581
|
+
, "sub" : 8834
|
582
|
+
, "sup" : 8835
|
583
|
+
, "nsub" : 8836
|
584
|
+
, "sube" : 8838
|
585
|
+
, "supe" : 8839
|
586
|
+
, "oplus" : 8853
|
587
|
+
, "otimes" : 8855
|
588
|
+
, "perp" : 8869
|
589
|
+
, "sdot" : 8901
|
590
|
+
, "lceil" : 8968
|
591
|
+
, "rceil" : 8969
|
592
|
+
, "lfloor" : 8970
|
593
|
+
, "rfloor" : 8971
|
594
|
+
, "lang" : 9001
|
595
|
+
, "rang" : 9002
|
596
|
+
, "loz" : 9674
|
597
|
+
, "spades" : 9824
|
598
|
+
, "clubs" : 9827
|
599
|
+
, "hearts" : 9829
|
600
|
+
, "diams" : 9830
|
601
|
+
}
|
602
|
+
|
603
|
+
Object.keys(sax.ENTITIES).forEach(function (key) {
|
604
|
+
var e = sax.ENTITIES[key]
|
605
|
+
var s = typeof e === 'number' ? String.fromCharCode(e) : e
|
606
|
+
sax.ENTITIES[key] = s
|
607
|
+
})
|
608
|
+
|
609
|
+
for (var S in sax.STATE) sax.STATE[sax.STATE[S]] = S
|
610
|
+
|
611
|
+
// shorthand
|
612
|
+
S = sax.STATE
|
613
|
+
|
614
|
+
function emit (parser, event, data) {
|
615
|
+
parser[event] && parser[event](data)
|
616
|
+
}
|
617
|
+
|
618
|
+
function emitNode (parser, nodeType, data) {
|
619
|
+
if (parser.textNode) closeText(parser)
|
620
|
+
emit(parser, nodeType, data)
|
621
|
+
}
|
622
|
+
|
623
|
+
function closeText (parser) {
|
624
|
+
parser.textNode = textopts(parser.opt, parser.textNode)
|
625
|
+
if (parser.textNode) emit(parser, "ontext", parser.textNode)
|
626
|
+
parser.textNode = ""
|
627
|
+
}
|
628
|
+
|
629
|
+
function textopts (opt, text) {
|
630
|
+
if (opt.trim) text = text.trim()
|
631
|
+
if (opt.normalize) text = text.replace(/\s+/g, " ")
|
632
|
+
return text
|
633
|
+
}
|
634
|
+
|
635
|
+
function error (parser, er) {
|
636
|
+
closeText(parser)
|
637
|
+
if (parser.trackPosition) {
|
638
|
+
er += "\nLine: "+parser.line+
|
639
|
+
"\nColumn: "+parser.column+
|
640
|
+
"\nChar: "+parser.c
|
641
|
+
}
|
642
|
+
er = new Error(er)
|
643
|
+
parser.error = er
|
644
|
+
emit(parser, "onerror", er)
|
645
|
+
return parser
|
646
|
+
}
|
647
|
+
|
648
|
+
function end (parser) {
|
649
|
+
if (!parser.closedRoot) strictFail(parser, "Unclosed root tag")
|
650
|
+
if ((parser.state !== S.BEGIN) && (parser.state !== S.TEXT)) error(parser, "Unexpected end")
|
651
|
+
closeText(parser)
|
652
|
+
parser.c = ""
|
653
|
+
parser.closed = true
|
654
|
+
emit(parser, "onend")
|
655
|
+
SAXParser.call(parser, parser.strict, parser.opt)
|
656
|
+
return parser
|
657
|
+
}
|
658
|
+
|
659
|
+
function strictFail (parser, message) {
|
660
|
+
if (typeof parser !== 'object' || !(parser instanceof SAXParser))
|
661
|
+
throw new Error('bad call to strictFail');
|
662
|
+
if (parser.strict) error(parser, message)
|
663
|
+
}
|
664
|
+
|
665
|
+
function newTag (parser) {
|
666
|
+
if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
|
667
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
668
|
+
, tag = parser.tag = { name : parser.tagName, attributes : {} }
|
669
|
+
|
670
|
+
// will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
|
671
|
+
if (parser.opt.xmlns) tag.ns = parent.ns
|
672
|
+
parser.attribList.length = 0
|
673
|
+
}
|
674
|
+
|
675
|
+
function qname (name, attribute) {
|
676
|
+
var i = name.indexOf(":")
|
677
|
+
, qualName = i < 0 ? [ "", name ] : name.split(":")
|
678
|
+
, prefix = qualName[0]
|
679
|
+
, local = qualName[1]
|
680
|
+
|
681
|
+
// <x "xmlns"="http://foo">
|
682
|
+
if (attribute && name === "xmlns") {
|
683
|
+
prefix = "xmlns"
|
684
|
+
local = ""
|
685
|
+
}
|
686
|
+
|
687
|
+
return { prefix: prefix, local: local }
|
688
|
+
}
|
689
|
+
|
690
|
+
function attrib (parser) {
|
691
|
+
if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]()
|
692
|
+
|
693
|
+
if (parser.attribList.indexOf(parser.attribName) !== -1 ||
|
694
|
+
parser.tag.attributes.hasOwnProperty(parser.attribName)) {
|
695
|
+
return parser.attribName = parser.attribValue = ""
|
696
|
+
}
|
697
|
+
|
698
|
+
if (parser.opt.xmlns) {
|
699
|
+
var qn = qname(parser.attribName, true)
|
700
|
+
, prefix = qn.prefix
|
701
|
+
, local = qn.local
|
702
|
+
|
703
|
+
if (prefix === "xmlns") {
|
704
|
+
// namespace binding attribute; push the binding into scope
|
705
|
+
if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
|
706
|
+
strictFail( parser
|
707
|
+
, "xml: prefix must be bound to " + XML_NAMESPACE + "\n"
|
708
|
+
+ "Actual: " + parser.attribValue )
|
709
|
+
} else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
|
710
|
+
strictFail( parser
|
711
|
+
, "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\n"
|
712
|
+
+ "Actual: " + parser.attribValue )
|
713
|
+
} else {
|
714
|
+
var tag = parser.tag
|
715
|
+
, parent = parser.tags[parser.tags.length - 1] || parser
|
716
|
+
if (tag.ns === parent.ns) {
|
717
|
+
tag.ns = Object.create(parent.ns)
|
718
|
+
}
|
719
|
+
tag.ns[local] = parser.attribValue
|
720
|
+
}
|
721
|
+
}
|
722
|
+
|
723
|
+
// defer onattribute events until all attributes have been seen
|
724
|
+
// so any new bindings can take effect; preserve attribute order
|
725
|
+
// so deferred events can be emitted in document order
|
726
|
+
parser.attribList.push([parser.attribName, parser.attribValue])
|
727
|
+
} else {
|
728
|
+
// in non-xmlns mode, we can emit the event right away
|
729
|
+
parser.tag.attributes[parser.attribName] = parser.attribValue
|
730
|
+
emitNode( parser
|
731
|
+
, "onattribute"
|
732
|
+
, { name: parser.attribName
|
733
|
+
, value: parser.attribValue } )
|
734
|
+
}
|
735
|
+
|
736
|
+
parser.attribName = parser.attribValue = ""
|
737
|
+
}
|
738
|
+
|
739
|
+
function openTag (parser, selfClosing) {
|
740
|
+
if (parser.opt.xmlns) {
|
741
|
+
// emit namespace binding events
|
742
|
+
var tag = parser.tag
|
743
|
+
|
744
|
+
// add namespace info to tag
|
745
|
+
var qn = qname(parser.tagName)
|
746
|
+
tag.prefix = qn.prefix
|
747
|
+
tag.local = qn.local
|
748
|
+
tag.uri = tag.ns[qn.prefix] || ""
|
749
|
+
|
750
|
+
if (tag.prefix && !tag.uri) {
|
751
|
+
strictFail(parser, "Unbound namespace prefix: "
|
752
|
+
+ JSON.stringify(parser.tagName))
|
753
|
+
tag.uri = qn.prefix
|
754
|
+
}
|
755
|
+
|
756
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
757
|
+
if (tag.ns && parent.ns !== tag.ns) {
|
758
|
+
Object.keys(tag.ns).forEach(function (p) {
|
759
|
+
emitNode( parser
|
760
|
+
, "onopennamespace"
|
761
|
+
, { prefix: p , uri: tag.ns[p] } )
|
762
|
+
})
|
763
|
+
}
|
764
|
+
|
765
|
+
// handle deferred onattribute events
|
766
|
+
// Note: do not apply default ns to attributes:
|
767
|
+
// http://www.w3.org/TR/REC-xml-names/#defaulting
|
768
|
+
for (var i = 0, l = parser.attribList.length; i < l; i ++) {
|
769
|
+
var nv = parser.attribList[i]
|
770
|
+
var name = nv[0]
|
771
|
+
, value = nv[1]
|
772
|
+
, qualName = qname(name, true)
|
773
|
+
, prefix = qualName.prefix
|
774
|
+
, local = qualName.local
|
775
|
+
, uri = prefix == "" ? "" : (tag.ns[prefix] || "")
|
776
|
+
, a = { name: name
|
777
|
+
, value: value
|
778
|
+
, prefix: prefix
|
779
|
+
, local: local
|
780
|
+
, uri: uri
|
781
|
+
}
|
782
|
+
|
783
|
+
// if there's any attributes with an undefined namespace,
|
784
|
+
// then fail on them now.
|
785
|
+
if (prefix && prefix != "xmlns" && !uri) {
|
786
|
+
strictFail(parser, "Unbound namespace prefix: "
|
787
|
+
+ JSON.stringify(prefix))
|
788
|
+
a.uri = prefix
|
789
|
+
}
|
790
|
+
parser.tag.attributes[name] = a
|
791
|
+
emitNode(parser, "onattribute", a)
|
792
|
+
}
|
793
|
+
parser.attribList.length = 0
|
794
|
+
}
|
795
|
+
|
796
|
+
parser.tag.isSelfClosing = !!selfClosing
|
797
|
+
|
798
|
+
// process the tag
|
799
|
+
parser.sawRoot = true
|
800
|
+
parser.tags.push(parser.tag)
|
801
|
+
emitNode(parser, "onopentag", parser.tag)
|
802
|
+
if (!selfClosing) {
|
803
|
+
// special case for <script> in non-strict mode.
|
804
|
+
if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
|
805
|
+
parser.state = S.SCRIPT
|
806
|
+
} else {
|
807
|
+
parser.state = S.TEXT
|
808
|
+
}
|
809
|
+
parser.tag = null
|
810
|
+
parser.tagName = ""
|
811
|
+
}
|
812
|
+
parser.attribName = parser.attribValue = ""
|
813
|
+
parser.attribList.length = 0
|
814
|
+
}
|
815
|
+
|
816
|
+
function closeTag (parser) {
|
817
|
+
if (!parser.tagName) {
|
818
|
+
strictFail(parser, "Weird empty close tag.")
|
819
|
+
parser.textNode += "</>"
|
820
|
+
parser.state = S.TEXT
|
821
|
+
return
|
822
|
+
}
|
823
|
+
|
824
|
+
if (parser.script) {
|
825
|
+
if (parser.tagName !== "script") {
|
826
|
+
parser.script += "</" + parser.tagName + ">"
|
827
|
+
parser.tagName = ""
|
828
|
+
parser.state = S.SCRIPT
|
829
|
+
return
|
830
|
+
}
|
831
|
+
emitNode(parser, "onscript", parser.script)
|
832
|
+
parser.script = ""
|
833
|
+
}
|
834
|
+
|
835
|
+
// first make sure that the closing tag actually exists.
|
836
|
+
// <a><b></c></b></a> will close everything, otherwise.
|
837
|
+
var t = parser.tags.length
|
838
|
+
var tagName = parser.tagName
|
839
|
+
if (!parser.strict) tagName = tagName[parser.looseCase]()
|
840
|
+
var closeTo = tagName
|
841
|
+
while (t --) {
|
842
|
+
var close = parser.tags[t]
|
843
|
+
if (close.name !== closeTo) {
|
844
|
+
// fail the first time in strict mode
|
845
|
+
strictFail(parser, "Unexpected close tag")
|
846
|
+
} else break
|
847
|
+
}
|
848
|
+
|
849
|
+
// didn't find it. we already failed for strict, so just abort.
|
850
|
+
if (t < 0) {
|
851
|
+
strictFail(parser, "Unmatched closing tag: "+parser.tagName)
|
852
|
+
parser.textNode += "</" + parser.tagName + ">"
|
853
|
+
parser.state = S.TEXT
|
854
|
+
return
|
855
|
+
}
|
856
|
+
parser.tagName = tagName
|
857
|
+
var s = parser.tags.length
|
858
|
+
while (s --> t) {
|
859
|
+
var tag = parser.tag = parser.tags.pop()
|
860
|
+
parser.tagName = parser.tag.name
|
861
|
+
emitNode(parser, "onclosetag", parser.tagName)
|
862
|
+
|
863
|
+
var x = {}
|
864
|
+
for (var i in tag.ns) x[i] = tag.ns[i]
|
865
|
+
|
866
|
+
var parent = parser.tags[parser.tags.length - 1] || parser
|
867
|
+
if (parser.opt.xmlns && tag.ns !== parent.ns) {
|
868
|
+
// remove namespace bindings introduced by tag
|
869
|
+
Object.keys(tag.ns).forEach(function (p) {
|
870
|
+
var n = tag.ns[p]
|
871
|
+
emitNode(parser, "onclosenamespace", { prefix: p, uri: n })
|
872
|
+
})
|
873
|
+
}
|
874
|
+
}
|
875
|
+
if (t === 0) parser.closedRoot = true
|
876
|
+
parser.tagName = parser.attribValue = parser.attribName = ""
|
877
|
+
parser.attribList.length = 0
|
878
|
+
parser.state = S.TEXT
|
879
|
+
}
|
880
|
+
|
881
|
+
function parseEntity (parser) {
|
882
|
+
var entity = parser.entity
|
883
|
+
, entityLC = entity.toLowerCase()
|
884
|
+
, num
|
885
|
+
, numStr = ""
|
886
|
+
if (parser.ENTITIES[entity])
|
887
|
+
return parser.ENTITIES[entity]
|
888
|
+
if (parser.ENTITIES[entityLC])
|
889
|
+
return parser.ENTITIES[entityLC]
|
890
|
+
entity = entityLC
|
891
|
+
if (entity.charAt(0) === "#") {
|
892
|
+
if (entity.charAt(1) === "x") {
|
893
|
+
entity = entity.slice(2)
|
894
|
+
num = parseInt(entity, 16)
|
895
|
+
numStr = num.toString(16)
|
896
|
+
} else {
|
897
|
+
entity = entity.slice(1)
|
898
|
+
num = parseInt(entity, 10)
|
899
|
+
numStr = num.toString(10)
|
900
|
+
}
|
901
|
+
}
|
902
|
+
entity = entity.replace(/^0+/, "")
|
903
|
+
if (numStr.toLowerCase() !== entity) {
|
904
|
+
strictFail(parser, "Invalid character entity")
|
905
|
+
return "&"+parser.entity + ";"
|
906
|
+
}
|
907
|
+
return String.fromCharCode(num)
|
908
|
+
}
|
909
|
+
|
910
|
+
function write (chunk) {
|
911
|
+
var parser = this
|
912
|
+
if (this.error) throw this.error
|
913
|
+
if (parser.closed) return error(parser,
|
914
|
+
"Cannot write after close. Assign an onready handler.")
|
915
|
+
if (chunk === null) return end(parser)
|
916
|
+
var i = 0, c = ""
|
917
|
+
while (parser.c = c = chunk.charAt(i++)) {
|
918
|
+
if (parser.trackPosition) {
|
919
|
+
parser.position ++
|
920
|
+
if (c === "\n") {
|
921
|
+
parser.line ++
|
922
|
+
parser.column = 0
|
923
|
+
} else parser.column ++
|
924
|
+
}
|
925
|
+
switch (parser.state) {
|
926
|
+
|
927
|
+
case S.BEGIN:
|
928
|
+
if (c === "<") {
|
929
|
+
parser.state = S.OPEN_WAKA
|
930
|
+
parser.startTagPosition = parser.position
|
931
|
+
} else if (not(whitespace,c)) {
|
932
|
+
// have to process this as a text node.
|
933
|
+
// weird, but happens.
|
934
|
+
strictFail(parser, "Non-whitespace before first tag.")
|
935
|
+
parser.textNode = c
|
936
|
+
parser.state = S.TEXT
|
937
|
+
}
|
938
|
+
continue
|
939
|
+
|
940
|
+
case S.TEXT:
|
941
|
+
if (parser.sawRoot && !parser.closedRoot) {
|
942
|
+
var starti = i-1
|
943
|
+
while (c && c!=="<" && c!=="&") {
|
944
|
+
c = chunk.charAt(i++)
|
945
|
+
if (c && parser.trackPosition) {
|
946
|
+
parser.position ++
|
947
|
+
if (c === "\n") {
|
948
|
+
parser.line ++
|
949
|
+
parser.column = 0
|
950
|
+
} else parser.column ++
|
951
|
+
}
|
952
|
+
}
|
953
|
+
parser.textNode += chunk.substring(starti, i-1)
|
954
|
+
}
|
955
|
+
if (c === "<") {
|
956
|
+
parser.state = S.OPEN_WAKA
|
957
|
+
parser.startTagPosition = parser.position
|
958
|
+
} else {
|
959
|
+
if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot))
|
960
|
+
strictFail(parser, "Text data outside of root node.")
|
961
|
+
if (c === "&") parser.state = S.TEXT_ENTITY
|
962
|
+
else parser.textNode += c
|
963
|
+
}
|
964
|
+
continue
|
965
|
+
|
966
|
+
case S.SCRIPT:
|
967
|
+
// only non-strict
|
968
|
+
if (c === "<") {
|
969
|
+
parser.state = S.SCRIPT_ENDING
|
970
|
+
} else parser.script += c
|
971
|
+
continue
|
972
|
+
|
973
|
+
case S.SCRIPT_ENDING:
|
974
|
+
if (c === "/") {
|
975
|
+
parser.state = S.CLOSE_TAG
|
976
|
+
} else {
|
977
|
+
parser.script += "<" + c
|
978
|
+
parser.state = S.SCRIPT
|
979
|
+
}
|
980
|
+
continue
|
981
|
+
|
982
|
+
case S.OPEN_WAKA:
|
983
|
+
// either a /, ?, !, or text is coming next.
|
984
|
+
if (c === "!") {
|
985
|
+
parser.state = S.SGML_DECL
|
986
|
+
parser.sgmlDecl = ""
|
987
|
+
} else if (is(whitespace, c)) {
|
988
|
+
// wait for it...
|
989
|
+
} else if (is(nameStart,c)) {
|
990
|
+
parser.state = S.OPEN_TAG
|
991
|
+
parser.tagName = c
|
992
|
+
} else if (c === "/") {
|
993
|
+
parser.state = S.CLOSE_TAG
|
994
|
+
parser.tagName = ""
|
995
|
+
} else if (c === "?") {
|
996
|
+
parser.state = S.PROC_INST
|
997
|
+
parser.procInstName = parser.procInstBody = ""
|
998
|
+
} else {
|
999
|
+
strictFail(parser, "Unencoded <")
|
1000
|
+
// if there was some whitespace, then add that in.
|
1001
|
+
if (parser.startTagPosition + 1 < parser.position) {
|
1002
|
+
var pad = parser.position - parser.startTagPosition
|
1003
|
+
c = new Array(pad).join(" ") + c
|
1004
|
+
}
|
1005
|
+
parser.textNode += "<" + c
|
1006
|
+
parser.state = S.TEXT
|
1007
|
+
}
|
1008
|
+
continue
|
1009
|
+
|
1010
|
+
case S.SGML_DECL:
|
1011
|
+
if ((parser.sgmlDecl+c).toUpperCase() === CDATA) {
|
1012
|
+
emitNode(parser, "onopencdata")
|
1013
|
+
parser.state = S.CDATA
|
1014
|
+
parser.sgmlDecl = ""
|
1015
|
+
parser.cdata = ""
|
1016
|
+
} else if (parser.sgmlDecl+c === "--") {
|
1017
|
+
parser.state = S.COMMENT
|
1018
|
+
parser.comment = ""
|
1019
|
+
parser.sgmlDecl = ""
|
1020
|
+
} else if ((parser.sgmlDecl+c).toUpperCase() === DOCTYPE) {
|
1021
|
+
parser.state = S.DOCTYPE
|
1022
|
+
if (parser.doctype || parser.sawRoot) strictFail(parser,
|
1023
|
+
"Inappropriately located doctype declaration")
|
1024
|
+
parser.doctype = ""
|
1025
|
+
parser.sgmlDecl = ""
|
1026
|
+
} else if (c === ">") {
|
1027
|
+
emitNode(parser, "onsgmldeclaration", parser.sgmlDecl)
|
1028
|
+
parser.sgmlDecl = ""
|
1029
|
+
parser.state = S.TEXT
|
1030
|
+
} else if (is(quote, c)) {
|
1031
|
+
parser.state = S.SGML_DECL_QUOTED
|
1032
|
+
parser.sgmlDecl += c
|
1033
|
+
} else parser.sgmlDecl += c
|
1034
|
+
continue
|
1035
|
+
|
1036
|
+
case S.SGML_DECL_QUOTED:
|
1037
|
+
if (c === parser.q) {
|
1038
|
+
parser.state = S.SGML_DECL
|
1039
|
+
parser.q = ""
|
1040
|
+
}
|
1041
|
+
parser.sgmlDecl += c
|
1042
|
+
continue
|
1043
|
+
|
1044
|
+
case S.DOCTYPE:
|
1045
|
+
if (c === ">") {
|
1046
|
+
parser.state = S.TEXT
|
1047
|
+
emitNode(parser, "ondoctype", parser.doctype)
|
1048
|
+
parser.doctype = true // just remember that we saw it.
|
1049
|
+
} else {
|
1050
|
+
parser.doctype += c
|
1051
|
+
if (c === "[") parser.state = S.DOCTYPE_DTD
|
1052
|
+
else if (is(quote, c)) {
|
1053
|
+
parser.state = S.DOCTYPE_QUOTED
|
1054
|
+
parser.q = c
|
1055
|
+
}
|
1056
|
+
}
|
1057
|
+
continue
|
1058
|
+
|
1059
|
+
case S.DOCTYPE_QUOTED:
|
1060
|
+
parser.doctype += c
|
1061
|
+
if (c === parser.q) {
|
1062
|
+
parser.q = ""
|
1063
|
+
parser.state = S.DOCTYPE
|
1064
|
+
}
|
1065
|
+
continue
|
1066
|
+
|
1067
|
+
case S.DOCTYPE_DTD:
|
1068
|
+
parser.doctype += c
|
1069
|
+
if (c === "]") parser.state = S.DOCTYPE
|
1070
|
+
else if (is(quote,c)) {
|
1071
|
+
parser.state = S.DOCTYPE_DTD_QUOTED
|
1072
|
+
parser.q = c
|
1073
|
+
}
|
1074
|
+
continue
|
1075
|
+
|
1076
|
+
case S.DOCTYPE_DTD_QUOTED:
|
1077
|
+
parser.doctype += c
|
1078
|
+
if (c === parser.q) {
|
1079
|
+
parser.state = S.DOCTYPE_DTD
|
1080
|
+
parser.q = ""
|
1081
|
+
}
|
1082
|
+
continue
|
1083
|
+
|
1084
|
+
case S.COMMENT:
|
1085
|
+
if (c === "-") parser.state = S.COMMENT_ENDING
|
1086
|
+
else parser.comment += c
|
1087
|
+
continue
|
1088
|
+
|
1089
|
+
case S.COMMENT_ENDING:
|
1090
|
+
if (c === "-") {
|
1091
|
+
parser.state = S.COMMENT_ENDED
|
1092
|
+
parser.comment = textopts(parser.opt, parser.comment)
|
1093
|
+
if (parser.comment) emitNode(parser, "oncomment", parser.comment)
|
1094
|
+
parser.comment = ""
|
1095
|
+
} else {
|
1096
|
+
parser.comment += "-" + c
|
1097
|
+
parser.state = S.COMMENT
|
1098
|
+
}
|
1099
|
+
continue
|
1100
|
+
|
1101
|
+
case S.COMMENT_ENDED:
|
1102
|
+
if (c !== ">") {
|
1103
|
+
strictFail(parser, "Malformed comment")
|
1104
|
+
// allow <!-- blah -- bloo --> in non-strict mode,
|
1105
|
+
// which is a comment of " blah -- bloo "
|
1106
|
+
parser.comment += "--" + c
|
1107
|
+
parser.state = S.COMMENT
|
1108
|
+
} else parser.state = S.TEXT
|
1109
|
+
continue
|
1110
|
+
|
1111
|
+
case S.CDATA:
|
1112
|
+
if (c === "]") parser.state = S.CDATA_ENDING
|
1113
|
+
else parser.cdata += c
|
1114
|
+
continue
|
1115
|
+
|
1116
|
+
case S.CDATA_ENDING:
|
1117
|
+
if (c === "]") parser.state = S.CDATA_ENDING_2
|
1118
|
+
else {
|
1119
|
+
parser.cdata += "]" + c
|
1120
|
+
parser.state = S.CDATA
|
1121
|
+
}
|
1122
|
+
continue
|
1123
|
+
|
1124
|
+
case S.CDATA_ENDING_2:
|
1125
|
+
if (c === ">") {
|
1126
|
+
if (parser.cdata) emitNode(parser, "oncdata", parser.cdata)
|
1127
|
+
emitNode(parser, "onclosecdata")
|
1128
|
+
parser.cdata = ""
|
1129
|
+
parser.state = S.TEXT
|
1130
|
+
} else if (c === "]") {
|
1131
|
+
parser.cdata += "]"
|
1132
|
+
} else {
|
1133
|
+
parser.cdata += "]]" + c
|
1134
|
+
parser.state = S.CDATA
|
1135
|
+
}
|
1136
|
+
continue
|
1137
|
+
|
1138
|
+
case S.PROC_INST:
|
1139
|
+
if (c === "?") parser.state = S.PROC_INST_ENDING
|
1140
|
+
else if (is(whitespace, c)) parser.state = S.PROC_INST_BODY
|
1141
|
+
else parser.procInstName += c
|
1142
|
+
continue
|
1143
|
+
|
1144
|
+
case S.PROC_INST_BODY:
|
1145
|
+
if (!parser.procInstBody && is(whitespace, c)) continue
|
1146
|
+
else if (c === "?") parser.state = S.PROC_INST_ENDING
|
1147
|
+
else parser.procInstBody += c
|
1148
|
+
continue
|
1149
|
+
|
1150
|
+
case S.PROC_INST_ENDING:
|
1151
|
+
if (c === ">") {
|
1152
|
+
emitNode(parser, "onprocessinginstruction", {
|
1153
|
+
name : parser.procInstName,
|
1154
|
+
body : parser.procInstBody
|
1155
|
+
})
|
1156
|
+
parser.procInstName = parser.procInstBody = ""
|
1157
|
+
parser.state = S.TEXT
|
1158
|
+
} else {
|
1159
|
+
parser.procInstBody += "?" + c
|
1160
|
+
parser.state = S.PROC_INST_BODY
|
1161
|
+
}
|
1162
|
+
continue
|
1163
|
+
|
1164
|
+
case S.OPEN_TAG:
|
1165
|
+
if (is(nameBody, c)) parser.tagName += c
|
1166
|
+
else {
|
1167
|
+
newTag(parser)
|
1168
|
+
if (c === ">") openTag(parser)
|
1169
|
+
else if (c === "/") parser.state = S.OPEN_TAG_SLASH
|
1170
|
+
else {
|
1171
|
+
if (not(whitespace, c)) strictFail(
|
1172
|
+
parser, "Invalid character in tag name")
|
1173
|
+
parser.state = S.ATTRIB
|
1174
|
+
}
|
1175
|
+
}
|
1176
|
+
continue
|
1177
|
+
|
1178
|
+
case S.OPEN_TAG_SLASH:
|
1179
|
+
if (c === ">") {
|
1180
|
+
openTag(parser, true)
|
1181
|
+
closeTag(parser)
|
1182
|
+
} else {
|
1183
|
+
strictFail(parser, "Forward-slash in opening tag not followed by >")
|
1184
|
+
parser.state = S.ATTRIB
|
1185
|
+
}
|
1186
|
+
continue
|
1187
|
+
|
1188
|
+
case S.ATTRIB:
|
1189
|
+
// haven't read the attribute name yet.
|
1190
|
+
if (is(whitespace, c)) continue
|
1191
|
+
else if (c === ">") openTag(parser)
|
1192
|
+
else if (c === "/") parser.state = S.OPEN_TAG_SLASH
|
1193
|
+
else if (is(nameStart, c)) {
|
1194
|
+
parser.attribName = c
|
1195
|
+
parser.attribValue = ""
|
1196
|
+
parser.state = S.ATTRIB_NAME
|
1197
|
+
} else strictFail(parser, "Invalid attribute name")
|
1198
|
+
continue
|
1199
|
+
|
1200
|
+
case S.ATTRIB_NAME:
|
1201
|
+
if (c === "=") parser.state = S.ATTRIB_VALUE
|
1202
|
+
else if (c === ">") {
|
1203
|
+
strictFail(parser, "Attribute without value")
|
1204
|
+
parser.attribValue = parser.attribName
|
1205
|
+
attrib(parser)
|
1206
|
+
openTag(parser)
|
1207
|
+
}
|
1208
|
+
else if (is(whitespace, c)) parser.state = S.ATTRIB_NAME_SAW_WHITE
|
1209
|
+
else if (is(nameBody, c)) parser.attribName += c
|
1210
|
+
else strictFail(parser, "Invalid attribute name")
|
1211
|
+
continue
|
1212
|
+
|
1213
|
+
case S.ATTRIB_NAME_SAW_WHITE:
|
1214
|
+
if (c === "=") parser.state = S.ATTRIB_VALUE
|
1215
|
+
else if (is(whitespace, c)) continue
|
1216
|
+
else {
|
1217
|
+
strictFail(parser, "Attribute without value")
|
1218
|
+
parser.tag.attributes[parser.attribName] = ""
|
1219
|
+
parser.attribValue = ""
|
1220
|
+
emitNode(parser, "onattribute",
|
1221
|
+
{ name : parser.attribName, value : "" })
|
1222
|
+
parser.attribName = ""
|
1223
|
+
if (c === ">") openTag(parser)
|
1224
|
+
else if (is(nameStart, c)) {
|
1225
|
+
parser.attribName = c
|
1226
|
+
parser.state = S.ATTRIB_NAME
|
1227
|
+
} else {
|
1228
|
+
strictFail(parser, "Invalid attribute name")
|
1229
|
+
parser.state = S.ATTRIB
|
1230
|
+
}
|
1231
|
+
}
|
1232
|
+
continue
|
1233
|
+
|
1234
|
+
case S.ATTRIB_VALUE:
|
1235
|
+
if (is(whitespace, c)) continue
|
1236
|
+
else if (is(quote, c)) {
|
1237
|
+
parser.q = c
|
1238
|
+
parser.state = S.ATTRIB_VALUE_QUOTED
|
1239
|
+
} else {
|
1240
|
+
strictFail(parser, "Unquoted attribute value")
|
1241
|
+
parser.state = S.ATTRIB_VALUE_UNQUOTED
|
1242
|
+
parser.attribValue = c
|
1243
|
+
}
|
1244
|
+
continue
|
1245
|
+
|
1246
|
+
case S.ATTRIB_VALUE_QUOTED:
|
1247
|
+
if (c !== parser.q) {
|
1248
|
+
if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_Q
|
1249
|
+
else parser.attribValue += c
|
1250
|
+
continue
|
1251
|
+
}
|
1252
|
+
attrib(parser)
|
1253
|
+
parser.q = ""
|
1254
|
+
parser.state = S.ATTRIB_VALUE_CLOSED
|
1255
|
+
continue
|
1256
|
+
|
1257
|
+
case S.ATTRIB_VALUE_CLOSED:
|
1258
|
+
if (is(whitespace, c)) {
|
1259
|
+
parser.state = S.ATTRIB
|
1260
|
+
} else if (c === ">") openTag(parser)
|
1261
|
+
else if (c === "/") parser.state = S.OPEN_TAG_SLASH
|
1262
|
+
else if (is(nameStart, c)) {
|
1263
|
+
strictFail(parser, "No whitespace between attributes")
|
1264
|
+
parser.attribName = c
|
1265
|
+
parser.attribValue = ""
|
1266
|
+
parser.state = S.ATTRIB_NAME
|
1267
|
+
} else strictFail(parser, "Invalid attribute name")
|
1268
|
+
continue
|
1269
|
+
|
1270
|
+
case S.ATTRIB_VALUE_UNQUOTED:
|
1271
|
+
if (not(attribEnd,c)) {
|
1272
|
+
if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_U
|
1273
|
+
else parser.attribValue += c
|
1274
|
+
continue
|
1275
|
+
}
|
1276
|
+
attrib(parser)
|
1277
|
+
if (c === ">") openTag(parser)
|
1278
|
+
else parser.state = S.ATTRIB
|
1279
|
+
continue
|
1280
|
+
|
1281
|
+
case S.CLOSE_TAG:
|
1282
|
+
if (!parser.tagName) {
|
1283
|
+
if (is(whitespace, c)) continue
|
1284
|
+
else if (not(nameStart, c)) {
|
1285
|
+
if (parser.script) {
|
1286
|
+
parser.script += "</" + c
|
1287
|
+
parser.state = S.SCRIPT
|
1288
|
+
} else {
|
1289
|
+
strictFail(parser, "Invalid tagname in closing tag.")
|
1290
|
+
}
|
1291
|
+
} else parser.tagName = c
|
1292
|
+
}
|
1293
|
+
else if (c === ">") closeTag(parser)
|
1294
|
+
else if (is(nameBody, c)) parser.tagName += c
|
1295
|
+
else if (parser.script) {
|
1296
|
+
parser.script += "</" + parser.tagName
|
1297
|
+
parser.tagName = ""
|
1298
|
+
parser.state = S.SCRIPT
|
1299
|
+
} else {
|
1300
|
+
if (not(whitespace, c)) strictFail(parser,
|
1301
|
+
"Invalid tagname in closing tag")
|
1302
|
+
parser.state = S.CLOSE_TAG_SAW_WHITE
|
1303
|
+
}
|
1304
|
+
continue
|
1305
|
+
|
1306
|
+
case S.CLOSE_TAG_SAW_WHITE:
|
1307
|
+
if (is(whitespace, c)) continue
|
1308
|
+
if (c === ">") closeTag(parser)
|
1309
|
+
else strictFail(parser, "Invalid characters in closing tag")
|
1310
|
+
continue
|
1311
|
+
|
1312
|
+
case S.TEXT_ENTITY:
|
1313
|
+
case S.ATTRIB_VALUE_ENTITY_Q:
|
1314
|
+
case S.ATTRIB_VALUE_ENTITY_U:
|
1315
|
+
switch(parser.state) {
|
1316
|
+
case S.TEXT_ENTITY:
|
1317
|
+
var returnState = S.TEXT, buffer = "textNode"
|
1318
|
+
break
|
1319
|
+
|
1320
|
+
case S.ATTRIB_VALUE_ENTITY_Q:
|
1321
|
+
var returnState = S.ATTRIB_VALUE_QUOTED, buffer = "attribValue"
|
1322
|
+
break
|
1323
|
+
|
1324
|
+
case S.ATTRIB_VALUE_ENTITY_U:
|
1325
|
+
var returnState = S.ATTRIB_VALUE_UNQUOTED, buffer = "attribValue"
|
1326
|
+
break
|
1327
|
+
}
|
1328
|
+
if (c === ";") {
|
1329
|
+
parser[buffer] += parseEntity(parser)
|
1330
|
+
parser.entity = ""
|
1331
|
+
parser.state = returnState
|
1332
|
+
}
|
1333
|
+
else if (is(entity, c)) parser.entity += c
|
1334
|
+
else {
|
1335
|
+
strictFail(parser, "Invalid character entity")
|
1336
|
+
parser[buffer] += "&" + parser.entity + c
|
1337
|
+
parser.entity = ""
|
1338
|
+
parser.state = returnState
|
1339
|
+
}
|
1340
|
+
continue
|
1341
|
+
|
1342
|
+
default:
|
1343
|
+
throw new Error(parser, "Unknown state: " + parser.state)
|
1344
|
+
}
|
1345
|
+
} // while
|
1346
|
+
// cdata blocks can get very big under normal conditions. emit and move on.
|
1347
|
+
// if (parser.state === S.CDATA && parser.cdata) {
|
1348
|
+
// emitNode(parser, "oncdata", parser.cdata)
|
1349
|
+
// parser.cdata = ""
|
1350
|
+
// }
|
1351
|
+
if (parser.position >= parser.bufferCheckPosition) checkBufferLength(parser)
|
1352
|
+
return parser
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
})(typeof exports === "undefined" ? sax = {} : exports)
|