Updating NPM dependencies

This commit is contained in:
Drew Heavner
2020-11-11 13:30:52 +00:00
committed by GitHub
parent 7a6fb66c63
commit bd487ef324
9068 changed files with 1400893 additions and 587661 deletions

View File

@@ -1,4 +1,4 @@
Copyright © 2016 Domenic Denicola <d@domenic.me>
Copyright © 2016–2020 Domenic Denicola <d@domenic.me>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@@ -2,27 +2,19 @@
const whatwgEncoding = require("whatwg-encoding");
// https://html.spec.whatwg.org/#encoding-sniffing-algorithm
module.exports = function sniffHTMLEncoding(buffer, options) {
module.exports = (buffer, { transportLayerEncodingLabel, defaultEncoding = "windows-1252" } = {}) => {
let encoding = whatwgEncoding.getBOMEncoding(buffer); // see https://github.com/whatwg/html/issues/1910
if (options === undefined) {
options = {};
}
if (encoding === null && options.transportLayerEncodingLabel !== undefined) {
encoding = whatwgEncoding.labelToName(options.transportLayerEncodingLabel);
if (encoding === null && transportLayerEncodingLabel !== undefined) {
encoding = whatwgEncoding.labelToName(transportLayerEncodingLabel);
}
if (encoding === null) {
encoding = prescanMetaCharset(buffer);
}
if (encoding === null && options.defaultEncoding !== undefined) {
encoding = options.defaultEncoding;
}
if (encoding === null) {
encoding = "windows-1252";
encoding = defaultEncoding;
}
return encoding;
@@ -35,8 +27,8 @@ function prescanMetaCharset(buffer) {
let c = buffer[i];
if (c === 0x3C) {
// "<"
let c1 = buffer[i + 1];
let c2 = buffer[i + 2];
const c1 = buffer[i + 1];
const c2 = buffer[i + 2];
const c3 = buffer[i + 3];
const c4 = buffer[i + 4];
const c5 = buffer[i + 5];
@@ -45,11 +37,10 @@ function prescanMetaCharset(buffer) {
i += 4;
for (; i < l; i++) {
c = buffer[i];
c1 = buffer[i + 1];
c2 = buffer[i + 2];
const cMinus1 = buffer[i - 1];
const cMinus2 = buffer[i - 2];
// --> (comment end)
if (c === 0x2D && c1 === 0x2D && c2 === 0x3E) {
i += 2;
if (c === 0x3E && cMinus1 === 0x2D && cMinus2 === 0x2D) {
break;
}
}
@@ -60,6 +51,7 @@ function prescanMetaCharset(buffer) {
(isSpaceCharacter(c5) || c5 === 0x2F)) {
// "meta" + space or /
i += 6;
const attributeList = new Set();
let gotPragma = false;
let needPragma = null;
let charset = null;
@@ -67,7 +59,8 @@ function prescanMetaCharset(buffer) {
let attrRes;
do {
attrRes = getAttribute(buffer, i, l);
if (attrRes.attr) {
if (attrRes.attr && !attributeList.has(attrRes.attr.name)) {
attributeList.add(attrRes.attr.name);
if (attrRes.attr.name === "http-equiv") {
gotPragma = attrRes.attr.value === "content-type";
} else if (attrRes.attr.name === "content" && !charset) {
@@ -140,7 +133,6 @@ function getAttribute(buffer, i, l) {
}
// ">"
if (c === 0x3E) {
i++;
break;
}
let name = "";
@@ -249,12 +241,12 @@ function extractCharacterEncodingFromMeta(string) {
let position = 0;
while (true) {
let subPosition = string.substring(position).search(/charset/i);
const indexOfCharset = string.substring(position).search(/charset/i);
if (subPosition === -1) {
if (indexOfCharset === -1) {
return null;
}
subPosition += "charset".length;
let subPosition = position + indexOfCharset + "charset".length;
while (isSpaceCharacter(string[subPosition].charCodeAt(0))) {
++subPosition;
@@ -290,10 +282,11 @@ function extractCharacterEncodingFromMeta(string) {
return null;
}
let end = string.substring(position + 1).search(/\x09|\x0A|\x0C|\x0D|\x20|;/);
if (end === -1) {
end = string.length;
}
const indexOfASCIIWhitespaceOrSemicolon = string.substring(position + 1).search(/\x09|\x0A|\x0C|\x0D|\x20|;/);
const end = indexOfASCIIWhitespaceOrSemicolon === -1 ?
string.length :
position + indexOfASCIIWhitespaceOrSemicolon + 1;
return whatwgEncoding.labelToName(string.substring(position, end));
}

View File

@@ -1,33 +1,27 @@
{
"_args": [
[
"html-encoding-sniffer@1.0.2",
"/Users/drew.heavner/Documents/Github/upload-google-play"
]
],
"_development": true,
"_from": "html-encoding-sniffer@1.0.2",
"_id": "html-encoding-sniffer@1.0.2",
"_from": "html-encoding-sniffer@^2.0.1",
"_id": "html-encoding-sniffer@2.0.1",
"_inBundle": false,
"_integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==",
"_integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==",
"_location": "/html-encoding-sniffer",
"_phantomChildren": {},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "html-encoding-sniffer@1.0.2",
"raw": "html-encoding-sniffer@^2.0.1",
"name": "html-encoding-sniffer",
"escapedName": "html-encoding-sniffer",
"rawSpec": "1.0.2",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "1.0.2"
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/jsdom"
],
"_resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz",
"_spec": "1.0.2",
"_where": "/Users/drew.heavner/Documents/Github/upload-google-play",
"_resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz",
"_shasum": "42a6dc4fd33f00281176e8b23759ca4e4fa185f3",
"_spec": "html-encoding-sniffer@^2.0.1",
"_where": "/home/codespace/workspace/upload-google-play/node_modules/jsdom",
"author": {
"name": "Domenic Denicola",
"email": "d@domenic.me",
@@ -36,13 +30,18 @@
"bugs": {
"url": "https://github.com/jsdom/html-encoding-sniffer/issues"
},
"bundleDependencies": false,
"dependencies": {
"whatwg-encoding": "^1.0.1"
"whatwg-encoding": "^1.0.5"
},
"deprecated": false,
"description": "Sniff the encoding from a HTML byte stream",
"devDependencies": {
"eslint": "^3.8.0",
"mocha": "^3.1.2"
"eslint": "^6.8.0",
"mocha": "^7.0.0"
},
"engines": {
"node": ">=10"
},
"files": [
"lib/"
@@ -60,8 +59,8 @@
"url": "git+https://github.com/jsdom/html-encoding-sniffer.git"
},
"scripts": {
"lint": "eslint lib test",
"lint": "eslint .",
"test": "mocha"
},
"version": "1.0.2"
"version": "2.0.1"
}