Current Folder
This commit is contained in:
1 parent
8b3382289b
commit
cfcada880d
4379 files changed
No files matched your search
-62
@@ -1,62 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Checks if a given buffer contains only correct UTF-8.
|
||||
* Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
|
||||
* Markus Kuhn.
|
||||
*
|
||||
* @param {Buffer} buf The buffer to check
|
||||
* @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
|
||||
* @public
|
||||
*/
|
||||
const isValidUTF8 = (buf) => {
|
||||
var len = buf.length;
|
||||
var i = 0;
|
||||
|
||||
while (i < len) {
|
||||
if (buf[i] < 0x80) { // 0xxxxxxx
|
||||
i++;
|
||||
} else if ((buf[i] & 0xe0) === 0xc0) { // 110xxxxx 10xxxxxx
|
||||
if (
|
||||
i + 1 === len ||
|
||||
(buf[i + 1] & 0xc0) !== 0x80 ||
|
||||
(buf[i] & 0xfe) === 0xc0 // overlong
|
||||
) {
|
||||
return false;
|
||||
} else {
|
||||
i += 2;
|
||||
}
|
||||
} else if ((buf[i] & 0xf0) === 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
|
||||
if (
|
||||
i + 2 >= len ||
|
||||
(buf[i + 1] & 0xc0) !== 0x80 ||
|
||||
(buf[i + 2] & 0xc0) !== 0x80 ||
|
||||
buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80 || // overlong
|
||||
buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0 // surrogate (U+D800 - U+DFFF)
|
||||
) {
|
||||
return false;
|
||||
} else {
|
||||
i += 3;
|
||||
}
|
||||
} else if ((buf[i] & 0xf8) === 0xf0) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
if (
|
||||
i + 3 >= len ||
|
||||
(buf[i + 1] & 0xc0) !== 0x80 ||
|
||||
(buf[i + 2] & 0xc0) !== 0x80 ||
|
||||
(buf[i + 3] & 0xc0) !== 0x80 ||
|
||||
buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80 || // overlong
|
||||
buf[i] === 0xf4 && buf[i + 1] > 0x8f || buf[i] > 0xf4 // > U+10FFFF
|
||||
) {
|
||||
return false;
|
||||
} else {
|
||||
i += 4;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = isValidUTF8;
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
try {
|
||||
module.exports = require('node-gyp-build')(__dirname);
|
||||
} catch (e) {
|
||||
module.exports = require('./fallback');
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
{
|
||||
"_from": "utf-8-validate@^5.0.2",
|
||||
"_id": "utf-8-validate@5.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-jtJM6fpGv8C1SoH4PtG22pGto6x+Y8uPprW0tw3//gGFhDDTiuksgradgFN6yRayDP4SyZZa6ZMGHLIa17+M8A==",
|
||||
"_location": "/utf-8-validate",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "utf-8-validate@^5.0.2",
|
||||
"name": "utf-8-validate",
|
||||
"escapedName": "utf-8-validate",
|
||||
"rawSpec": "^5.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/websocket"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.3.tgz",
|
||||
"_shasum": "3b64e418ad2ff829809025fdfef595eab2f03a27",
|
||||
"_spec": "utf-8-validate@^5.0.2",
|
||||
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\BackendServers\\node_modules\\websocket",
|
||||
"author": {
|
||||
"name": "Einar Otto Stangvik",
|
||||
"email": "einaros@gmail.com",
|
||||
"url": "http://2x.io"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/websockets/utf-8-validate/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"node-gyp-build": "^4.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Check if a buffer contains valid UTF-8",
|
||||
"devDependencies": {
|
||||
"mocha": "^8.0.1",
|
||||
"prebuildify": "^4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/websockets/utf-8-validate",
|
||||
"keywords": [
|
||||
"utf-8-validate"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "utf-8-validate",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/websockets/utf-8-validate.git"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "node-gyp-build",
|
||||
"prebuild": "prebuildify --napi",
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "5.0.3"
|
||||
}
|
||||
Reference in new issue
Block a user