Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: websockets/utf-8-validate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.0.5
Choose a base ref
...
head repository: websockets/utf-8-validate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.0.6
Choose a head ref
  • 13 commits
  • 7 files changed
  • 1 contributor

Commits on May 5, 2021

  1. Copy the full SHA
    7396426 View commit details

Commits on May 24, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e3e7742 View commit details
  2. [ci] Do not test on node 10

    Node.js 10 is no longer supported.
    lpinca committed May 24, 2021
    Copy the full SHA
    4d8745d View commit details
  3. [ci] Test on node 16

    lpinca committed May 24, 2021
    Copy the full SHA
    64945c3 View commit details
  4. [pkg] Add engines field

    lpinca committed May 24, 2021
    Copy the full SHA
    1011304 View commit details

Commits on Aug 3, 2021

  1. [license] Fix license text

    lpinca committed Aug 3, 2021
    Copy the full SHA
    0b584e4 View commit details

Commits on Aug 4, 2021

  1. Copy the full SHA
    ac24ec0 View commit details

Commits on Sep 5, 2021

  1. Copy the full SHA
    268eb02 View commit details
  2. Copy the full SHA
    54a069c View commit details
  3. Copy the full SHA
    9a253c6 View commit details

Commits on Sep 26, 2021

  1. Copy the full SHA
    c81c7da View commit details
  2. Copy the full SHA
    45439cc View commit details
  3. [dist] 5.0.6

    lpinca committed Sep 26, 2021
    Copy the full SHA
    f74964c View commit details
Showing with 46 additions and 29 deletions.
  1. +26 −14 .github/workflows/ci.yml
  2. +0 −2 LICENSE
  3. +1 −2 README.md
  4. +1 −1 appveyor.yml
  5. +6 −1 binding.gyp
  6. +6 −3 package.json
  7. +6 −6 src/validation.c
40 changes: 26 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -9,40 +9,52 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
arch:
- x64
- x86
node:
- 10
- 12
- 14
- 16
os:
- macOS-latest
- ubuntu-16.04
- macos-11
- ubuntu-18.04
- windows-latest
exclude:
- arch: x86
os: macos-11
- arch: x86
os: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
architecture: ${{ matrix.arch }}
- run: npm install
- run: npm test
- run: npm run prebuild
if: matrix.node == 14 && startsWith(github.ref, 'refs/tags/')
- run: npm run prebuild-ia32
if:
matrix.node == 14 && matrix.os == 'windows-latest' &&
startsWith(github.ref, 'refs/tags/')
matrix.node == 14 && matrix.os != 'macos-11' && startsWith(github.ref,
'refs/tags/')
- run: npm run prebuild-darwin-x64+arm64
if:
matrix.node == 14 && matrix.os == 'macos-11' && startsWith(github.ref,
'refs/tags/')
- run: npm run prebuild-linux-arm
if:
matrix.node == 14 && matrix.os == 'ubuntu-16.04' &&
matrix.node == 14 && matrix.os == 'ubuntu-18.04' &&
startsWith(github.ref, 'refs/tags/')
- uses: actions/upload-artifact@v2
if: matrix.node == 14 && startsWith(github.ref, 'refs/tags/')
with:
name: ${{ matrix.os }}
path: prebuilds
retention-days: 1
release:
if: startsWith(github.ref, 'refs/tags/')
needs: test
runs-on: ubuntu-16.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
@@ -51,17 +63,17 @@ jobs:
- run: echo ::set-output name=version::$(git describe --tags)
id: get_version
- run:
tar -cvf "${{ steps.get_version.outputs.version }}-darwin-x64.tar" -C
"prebuilds/macOS-latest" .
tar -cvf "${{ steps.get_version.outputs.version
}}-darwin-x64+arm64.tar" -C "prebuilds/macos-11" .
- run:
tar -cvf "${{ steps.get_version.outputs.version }}-linux-arm.tar" -C
"prebuilds/ubuntu-16.04" linux-arm
"prebuilds/ubuntu-18.04" linux-arm
- run:
tar -cvf "${{ steps.get_version.outputs.version }}-linux-arm64.tar" -C
"prebuilds/ubuntu-16.04" linux-arm64
"prebuilds/ubuntu-18.04" linux-arm64
- run:
tar -cvf "${{ steps.get_version.outputs.version }}-linux-x64.tar" -C
"prebuilds/ubuntu-16.04" linux-x64
"prebuilds/ubuntu-18.04" linux-x64
- run:
tar -cvf "${{ steps.get_version.outputs.version }}-win32-ia32.tar" -C
"prebuilds/windows-latest" win32-ia32
2 changes: 0 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
The MIT License (MIT)

Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)

Permission is hereby granted, free of charge, to any person obtaining a copy
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# 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://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)
[![Linux/macOS/Windows Build](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)

Check if a buffer contains valid UTF-8 encoded text.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ build: off
configuration: Release
environment:
matrix:
- nodejs_version: "16"
- nodejs_version: "14"
- nodejs_version: "12"
- nodejs_version: "10"
platform:
- x86
matrix:
7 changes: 6 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
@@ -3,7 +3,12 @@
{
'target_name': 'validation',
'sources': ['src/validation.c'],
'cflags': ['-std=c99']
'cflags': ['-std=c99'],
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.7',
'OTHER_CFLAGS': ['-arch x86_64', '-arch arm64'],
'OTHER_LDFLAGS': ['-arch x86_64', '-arch arm64']
}
}
]
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "utf-8-validate",
"version": "5.0.5",
"version": "5.0.6",
"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 --strip",
"prebuild-ia32": "prebuildify --arch=ia32 --napi --strip",
"prebuild-darwin-x64+arm64": "prebuildify --arch x64+arm64 --napi --strip",
"prebuild-linux-arm": "prebuildify-cross -i linux-armv6 -i linux-armv7 -i linux-arm64 --napi --strip",
"test": "mocha"
},
@@ -27,7 +30,7 @@
"node-gyp-build": "^4.2.0"
},
"devDependencies": {
"mocha": "^8.0.1",
"mocha": "^9.0.3",
"node-gyp": "^7.1.2",
"prebuildify": "^4.0.0",
"prebuildify-cross": "^4.0.0"
12 changes: 6 additions & 6 deletions src/validation.c
Original file line number Diff line number Diff line change
@@ -55,9 +55,9 @@ napi_value IsValidUTF8(napi_env env, napi_callback_info info) {
(buf[i] & 0xfe) == 0xc0 // overlong
) {
break;
} else {
i += 2;
}

i += 2;
} else if ((buf[i] & 0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
if (
i + 2 >= len ||
@@ -67,9 +67,9 @@ napi_value IsValidUTF8(napi_env env, napi_callback_info info) {
(buf[i] == 0xed && (buf[i + 1] & 0xe0) == 0xa0) // surrogate (U+D800 - U+DFFF)
) {
break;
} else {
i += 3;
}

i += 3;
} else if ((buf[i] & 0xf8) == 0xf0) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
if (
i + 3 >= len ||
@@ -80,9 +80,9 @@ napi_value IsValidUTF8(napi_env env, napi_callback_info info) {
(buf[i] == 0xf4 && buf[i + 1] > 0x8f) || buf[i] > 0xf4 // > U+10FFFF
) {
break;
} else {
i += 4;
}

i += 4;
} else {
break;
}