utf-8-validate
Advanced tools
Comparing version 5.0.4 to 5.0.5
@@ -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.4", | ||
"version": "5.0.5", | ||
"description": "Check if a buffer contains valid UTF-8", | ||
@@ -9,3 +9,4 @@ "main": "index.js", | ||
"prebuild": "prebuildify --napi --strip", | ||
"prebuild-linux-arm": "prebuildify-cross -i linux-armv6 -i linux-armv7 --napi --strip", | ||
"prebuild-ia32": "prebuildify --arch=ia32 --napi --strip", | ||
"prebuild-linux-arm": "prebuildify-cross -i linux-armv6 -i linux-armv7 -i linux-arm64 --napi --strip", | ||
"test": "mocha" | ||
@@ -12,0 +13,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.com/websockets/utf-8-validate.svg?branch=master)](https://travis-ci.com/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) | ||
[![Build Status](https://img.shields.io/github/workflow/status/websockets/utf-8-validate/CI/master?label=build)](https://github.com/websockets/utf-8-validate/actions?query=workflow%3ACI+branch%3Amaster) | ||
[![Windows x86 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) | ||
@@ -7,0 +7,0 @@ Check if a buffer contains valid UTF-8 encoded text. |
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
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
314805
1
61