Socket
Socket
Sign inDemoInstall

utf-8-validate

Package Overview
Dependencies
Maintainers
4
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utf-8-validate - npm Package Compare versions

Comparing version 5.0.2 to 5.0.10

prebuilds/darwin-x64+arm64/node.napi.node

24

fallback.js

@@ -12,8 +12,8 @@ 'use strict';

*/
const isValidUTF8 = (buf) => {
var len = buf.length;
var i = 0;
function isValidUTF8(buf) {
const len = buf.length;
let i = 0;
while (i < len) {
if (buf[i] < 0x80) { // 0xxxxxxx
if ((buf[i] & 0x80) === 0x00) { // 0xxxxxxx
i++;

@@ -27,5 +27,5 @@ } else if ((buf[i] & 0xe0) === 0xc0) { // 110xxxxx 10xxxxxx

return false;
} else {
i += 2;
}
i += 2;
} else if ((buf[i] & 0xf0) === 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx

@@ -37,8 +37,8 @@ if (

buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80 || // overlong
buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0 // surrogate (U+D800 - U+DFFF)
buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0 // surrogate (U+D800 - U+DFFF)
) {
return false;
} else {
i += 3;
}
i += 3;
} else if ((buf[i] & 0xf8) === 0xf0) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx

@@ -54,5 +54,5 @@ if (

return false;
} else {
i += 4;
}
i += 4;
} else {

@@ -64,4 +64,4 @@ return false;

return true;
};
}
module.exports = isValidUTF8;
{
"name": "utf-8-validate",
"version": "5.0.2",
"version": "5.0.10",
"description": "Check if a buffer contains valid UTF-8",
"main": "index.js",
"engines": {
"node": ">=6.14.2"
},
"scripts": {
"install": "node-gyp-build",
"prebuild": "prebuildify --napi",
"prebuild": "prebuildify --napi --strip --target=14.0.0",
"prebuild-darwin-x64+arm64": "prebuildify --arch x64+arm64 --napi --strip --target=14.0.0",
"test": "mocha"

@@ -25,8 +29,9 @@ },

"dependencies": {
"node-gyp-build": "~3.7.0"
"node-gyp-build": "^4.3.0"
},
"devDependencies": {
"mocha": "~5.2.0",
"prebuildify": "~2.10.0"
"mocha": "^10.0.0",
"node-gyp": "^9.1.0",
"prebuildify": "^5.0.0"
}
}
# utf-8-validate
[![Version npm](https://img.shields.io/npm/v/utf-8-validate.svg)](https://www.npmjs.com/package/utf-8-validate)
[![Build Status](https://travis-ci.org/websockets/utf-8-validate.svg?branch=master)](https://travis-ci.org/websockets/utf-8-validate)
[![Windows Build](https://ci.appveyor.com/api/projects/status/github/websockets/utf-8-validate?branch=master&svg=true)](https://ci.appveyor.com/project/lpinca/utf-8-validate)
[![Version npm](https://img.shields.io/npm/v/utf-8-validate.svg?logo=npm)](https://www.npmjs.com/package/utf-8-validate)
[![Linux/macOS/Windows Build](https://img.shields.io/github/workflow/status/websockets/utf-8-validate/CI/master?label=build&logo=github)](https://github.com/websockets/utf-8-validate/actions?query=workflow%3ACI+branch%3Amaster)

@@ -16,3 +15,4 @@ Check if a buffer contains valid UTF-8 encoded text.

The `--save-optional` flag tells npm to save the package in your package.json
under the [`optionalDependencies`](https://docs.npmjs.com/files/package.json#optionaldependencies)
under the
[`optionalDependencies`](https://docs.npmjs.com/files/package.json#optionaldependencies)
key.

@@ -19,0 +19,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc