initial commit

This commit is contained in:
2026-03-22 03:21:45 +02:00
commit 897fea9f4e
15431 changed files with 2548840 additions and 0 deletions

3
node_modules/isbinaryfile/.github/FUNDING.yml generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# These are supported funding model platforms
github: gjtorikian

18
node_modules/isbinaryfile/.github/dependabot.yml generated vendored Normal file
View File

@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
- package-ecosystem: npm
directory: "/"
schedule:
interval: cron
cronjob: "0 0 21 3,6,9,12 *"
timezone: "Etc/UTC"
open-pull-requests-limit: 10
groups:
npm-dependencies:
patterns:
- "*"

View File

@@ -0,0 +1,34 @@
name: PR auto-{approve,merge}
on:
pull_request_target:
permissions:
pull-requests: write
contents: write
jobs:
dependabot:
name: Dependabot
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Fetch Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve Dependabot PR
if: ${{steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major'}}
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Merge Dependabot PR
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

31
node_modules/isbinaryfile/.github/workflows/ci.yml generated vendored Normal file
View File

@@ -0,0 +1,31 @@
name: Node CI
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ['24']
steps:
- uses: actions/checkout@v6
- name: Set up Node
uses: gjtorikian/actions/setup-languages@main
with:
node: true
node-version: ${{ matrix.node-version }}
- name: Build Typescript
run: npm run build
- name: Run tests
run: npm test

View File

@@ -0,0 +1,29 @@
name: Publish Package
on:
push:
tags:
- 'v*'
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
# Ensure npm 11.5.1 or later is installed
- name: Update npm
run: npm install -g npm@latest
- run: npm ci
- run: npm run build --if-present
- run: npm test
- run: npm publish --provenance --access public

View File

@@ -0,0 +1,19 @@
name: Release Please
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node

4
node_modules/isbinaryfile/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,4 @@
.vscode/
node_modules
npm-debug.log
/lib

6
node_modules/isbinaryfile/.oxlintrc.json generated vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"rules": {
"no-bitwise": "off"
}
}

5
node_modules/isbinaryfile/.prettierrc generated vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true
}

View File

@@ -0,0 +1,3 @@
{
".": "6.0.0"
}

23
node_modules/isbinaryfile/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,23 @@
# Changelog
## [6.0.0](https://github.com/gjtorikian/isBinaryFile/compare/5.0.0...v6.0.0) (2025-12-05)
### ⚠ BREAKING CHANGES
* add encoding hints
### Features
* add encoding hints ([7171398](https://github.com/gjtorikian/isBinaryFile/commit/7171398fa2ff2c09b3a2cc4257120e0d77f43fde))
### Bug Fixes
* fix protobuf processing causing index out of range errors ([913ecb0](https://github.com/gjtorikian/isBinaryFile/commit/913ecb0bea60f99d679c94143fb9e1c3a76a3fb4))
* fix protobuf processing causing index out of range errors ([d39d2c0](https://github.com/gjtorikian/isBinaryFile/commit/d39d2c0d80014e387a5c906ff3ed6d0b53bdbe2e))
* handle errors in isBinaryFile function with try-catch 🐛 ([ae76dba](https://github.com/gjtorikian/isBinaryFile/commit/ae76dba724bccb86ecd094601247bf2edc234fe8))
* handle errors in isBinaryFile function with try-catch 🐛 ([a78a3b8](https://github.com/gjtorikian/isBinaryFile/commit/a78a3b8736e41ef3659737c2ece2454972b5c4d4))
* handle UTF-8 multibyte sequences truncated at buffer boundary ([a9d483b](https://github.com/gjtorikian/isBinaryFile/commit/a9d483b94d1d3bffd85f3ace95ddcf183d774976))
* handle UTF-8 multibyte sequences truncated at buffer boundary ([4832a7c](https://github.com/gjtorikian/isBinaryFile/commit/4832a7c129cbc218a8281ca6d00e87ff899ab616))
* update CI workflow triggers for pull requests 🔧 ([298e604](https://github.com/gjtorikian/isBinaryFile/commit/298e604400e05e38916769363f7f672062b3bd9b))

22
node_modules/isbinaryfile/LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,22 @@
Copyright (c) 2019 Garen J. Torikian
MIT License
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:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

116
node_modules/isbinaryfile/README.md generated vendored Normal file
View File

@@ -0,0 +1,116 @@
# isBinaryFile
Detects if a file is binary in Node.js. Similar to [Perl's `-B` switch](http://stackoverflow.com/questions/899206/how-does-perl-know-a-file-is-binary), in that:
- it reads the first few thousand bytes of a file
- checks for a `null` byte; if it's found, it's binary
- flags non-ASCII characters. After a certain number of "weird" characters, the file is flagged as binary
Much of the logic is pretty much ported from [ag](https://github.com/ggreer/the_silver_searcher).
Note: if the file doesn't exist or is a directory, an error is thrown.
## Installation
```
npm install isbinaryfile
```
## Usage
Returns `Promise<boolean>` (or just `boolean` for `*Sync`). `true` if the file is binary, `false` otherwise.
### isBinaryFile(filepath[, options])
- `filepath` - a `string` indicating the path to the file.
- `options` - an optional object with the following properties:
- `encoding` - an encoding hint (see [Encoding Hints](#encoding-hints) below)
### isBinaryFile(bytes[, options])
- `bytes` - a `Buffer` of the file's contents.
- `options` - an optional object with the following properties:
- `size` - the size of the buffer (defaults to `bytes.length`)
- `encoding` - an encoding hint (see [Encoding Hints](#encoding-hints) below)
### isBinaryFileSync(filepath[, options])
Synchronous version of `isBinaryFile`.
### isBinaryFileSync(bytes[, options])
Synchronous version of `isBinaryFile` for buffers.
### Examples
Here's an arbitrary usage:
```javascript
import { isBinaryFile, isBinaryFileSync } from 'isbinaryfile';
import fs from 'fs';
const filename = 'fixtures/pdf.pdf';
// Async with file path
const result = await isBinaryFile(filename);
if (result) {
console.log('It is binary!');
} else {
console.log('No it is not.');
}
// Sync with buffer
const bytes = fs.readFileSync(filename);
console.log(isBinaryFileSync(bytes)); // true or false
// With explicit size option
const partialBuffer = Buffer.alloc(100);
fs.readSync(fs.openSync(filename, 'r'), partialBuffer, 0, 100, 0);
console.log(isBinaryFileSync(partialBuffer, { size: 100 }));
```
### Encoding Hints
For files that use non-UTF-8 encodings, you can provide encoding hints to improve detection accuracy:
```javascript
import { isBinaryFile, isBinaryFileSync } from 'isbinaryfile';
// UTF-16 files without BOM are auto-detected in most cases
const result1 = await isBinaryFile('utf16-file.txt');
// Or provide explicit encoding hint
const result2 = await isBinaryFile('utf16-file.txt', { encoding: 'utf-16' });
// ISO-8859-1 / Latin-1 encoded files
const result3 = isBinaryFileSync('german-text.txt', { encoding: 'latin1' });
// CJK encoded files (Big5, GB2312, EUC-KR, etc.)
const result4 = isBinaryFileSync('chinese-big5.txt', { encoding: 'big5' });
const result5 = isBinaryFileSync('korean-text.txt', { encoding: 'euc-kr' });
// Generic CJK hint when exact encoding is unknown
const result6 = isBinaryFileSync('asian-text.txt', { encoding: 'cjk' });
```
#### Supported Encoding Hints
| Hint | Description |
| ------------ | ------------------------------------------ |
| `utf-16` | UTF-16 (auto-detect endianness) |
| `utf-16le` | UTF-16 Little Endian |
| `utf-16be` | UTF-16 Big Endian |
| `latin1` | ISO-8859-1 / Latin-1 |
| `iso-8859-1` | Alias for latin1 |
| `cjk` | Generic CJK (use when encoding is unknown) |
| `big5` | Traditional Chinese |
| `gb2312` | Simplified Chinese |
| `gbk` | Extended GB2312 |
| `euc-kr` | Korean |
| `shift-jis` | Japanese |
**Note:** UTF-16 without BOM is automatically detected in most cases without needing a hint.
## Testing
Run `npm test`.

12
node_modules/isbinaryfile/jestconfig.json generated vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"preset": "ts-jest/presets/default-esm",
"extensionsToTreatAsEsm": [".ts"],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
"transform": {
"^.+\\.tsx?$": ["ts-jest", { "useESM": true }]
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
}

9590
node_modules/isbinaryfile/package-lock.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

66
node_modules/isbinaryfile/package.json generated vendored Normal file
View File

@@ -0,0 +1,66 @@
{
"name": "isbinaryfile",
"description": "Detects if a file is binary in Node.js. Similar to Perl's -B.",
"version": "6.0.0",
"type": "commonjs",
"keywords": [
"text",
"binary",
"encoding",
"istext",
"is text",
"isbinary",
"is binary",
"is text or binary",
"is text or binary file",
"isbinaryfile",
"is binary file",
"istextfile",
"is text file"
],
"devDependencies": {
"@types/jest": "^30",
"@types/node": "^24",
"jest": "^30.2.0",
"oxlint": "^1.31",
"prettier": "^3",
"ts-jest": "^29.1.4",
"typescript": "^5"
},
"engines": {
"node": ">= 24.0.0"
},
"files": [
"lib/**/*"
],
"license": "MIT",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"require": "./lib/index.js",
"default": "./lib/index.js"
}
},
"maintainers": [
{
"name": "Garen J. Torikian",
"email": "gjtorikian@gmail.com"
}
],
"funding": "https://github.com/sponsors/gjtorikian/",
"repository": {
"type": "git",
"url": "https://github.com/gjtorikian/isBinaryFile"
},
"scripts": {
"build": "tsc",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"lint": "oxlint src test",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
"test": "NODE_OPTIONS='--experimental-vm-modules' jest --config jestconfig.json",
"watch": "tsc -w"
}
}

18
node_modules/isbinaryfile/release-please-config.json generated vendored Normal file
View File

@@ -0,0 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"packages": {
".": {
"release-type": "node",
"changelog-sections": [
{ "type": "feat", "section": "Features" },
{ "type": "fix", "section": "Bug Fixes" },
{ "type": "perf", "section": "Performance Improvements" },
{ "type": "docs", "section": "Documentation", "hidden": true },
{ "type": "chore", "section": "Miscellaneous", "hidden": true },
{ "type": "style", "hidden": true },
{ "type": "refactor", "hidden": true },
{ "type": "test", "hidden": true }
]
}
}
}

36
node_modules/isbinaryfile/release.md generated vendored Normal file
View File

@@ -0,0 +1,36 @@
## Release
This project uses [release-please](https://github.com/googleapis/release-please) for automated releases with [conventional commits](https://www.conventionalcommits.org/).
### Commit Message Format
Version bumps are determined automatically from commit messages:
| Commit Type | Example | Version Bump |
| ------------------------------ | ------------------------------- | --------------------- |
| `feat:` | `feat: add streaming detection` | Minor (5.0.0 → 5.1.0) |
| `fix:` | `fix: handle empty buffers` | Patch (5.0.0 → 5.0.1) |
| `feat!:` or `BREAKING CHANGE:` | `feat!: require Node 24` | Major (5.0.0 → 6.0.0) |
| `docs:`, `chore:`, `test:` | `docs: update examples` | No release |
### Release Flow
1. Create a feature branch and make changes
2. Commit using conventional commit format (e.g., `feat: add new feature`)
3. Open a PR and merge to `main`
4. **release-please** automatically creates/updates a Release PR
5. The Release PR accumulates changes and shows the pending changelog
6. When ready to release, merge the Release PR
7. A git tag and GitHub Release are created automatically
8. GitHub Actions publishes to npm
### How the Workflows Interact
Two GitHub Actions workflows handle releases:
| Workflow | Trigger | Purpose |
| -------------------- | ------------------- | -------------------------------------------------------------------- |
| `release-please.yml` | Push to `main` | Creates Release PR, manages versions and changelog, creates git tags |
| `publish.yml` | Git tag `v*` pushed | Builds, tests, and publishes to npm via OIDC |
When you merge a Release PR, `release-please.yml` creates a git tag (e.g., `v5.1.0`), which triggers `publish.yml` to publish to npm.

127
node_modules/isbinaryfile/src/encoding.ts generated vendored Normal file
View File

@@ -0,0 +1,127 @@
/**
* Encoding hints to improve text detection accuracy for non-UTF-8 files.
*/
export type EncodingHint =
| 'utf-16' // UTF-16 (auto-detect endianness)
| 'utf-16le' // UTF-16 Little Endian
| 'utf-16be' // UTF-16 Big Endian
| 'latin1' // ISO-8859-1 / Latin-1
| 'iso-8859-1' // Alias for latin1
| 'cjk' // Generic CJK (Big5, GB2312, GBK, EUC-KR, Shift-JIS)
| 'big5' // Traditional Chinese
| 'gb2312' // Simplified Chinese
| 'gbk' // Extended GB2312
| 'euc-kr' // Korean
| 'shift-jis'; // Japanese
const MAX_BYTES = 512;
/**
* Detect UTF-16 without BOM by analyzing null byte patterns.
* UTF-16LE: ASCII chars have nulls at odd positions (e.g., 't\0e\0s\0t\0')
* UTF-16BE: ASCII chars have nulls at even positions (e.g., '\0t\0e\0s\0t')
*/
export function detectUtf16NoBom(fileBuffer: Buffer, bytesRead: number): 'utf-16le' | 'utf-16be' | null {
if (bytesRead < 4) return null;
const scanLength = Math.min(bytesRead, MAX_BYTES);
let nullsAtEven = 0;
let nullsAtOdd = 0;
for (let i = 0; i < scanLength; i++) {
if (fileBuffer[i] === 0x00) {
if (i % 2 === 0) nullsAtEven++;
else nullsAtOdd++;
}
}
const totalNulls = nullsAtEven + nullsAtOdd;
// For UTF-16 ASCII text, roughly 30-70% of total bytes should be nulls
// (pure ASCII = 50%, mixed with non-ASCII = less)
if (totalNulls > scanLength * 0.3 && totalNulls < scanLength * 0.7) {
// UTF-16LE: nulls at odd positions (high bytes of little-endian chars)
if (nullsAtOdd > nullsAtEven * 3) return 'utf-16le';
// UTF-16BE: nulls at even positions (high bytes of big-endian chars)
if (nullsAtEven > nullsAtOdd * 3) return 'utf-16be';
}
return null;
}
/**
* Check if the buffer is valid text for the given encoding hint.
* Returns true if it's valid text (not binary), false if binary.
*/
export function isTextWithEncodingHint(
fileBuffer: Buffer,
bytesRead: number,
encoding: EncodingHint
): boolean {
const scanLength = Math.min(bytesRead, MAX_BYTES);
// Handle UTF-16 hints
if (encoding === 'utf-16' || encoding === 'utf-16le' || encoding === 'utf-16be') {
// For UTF-16, null bytes are expected, so we just check for control characters
for (let i = 0; i < scanLength; i += 2) {
const byte1 = fileBuffer[i];
const byte2 = i + 1 < scanLength ? fileBuffer[i + 1] : 0;
// In UTF-16, check for problematic control characters
// Allow common ones: tab (0x09), newline (0x0A), carriage return (0x0D)
if (encoding === 'utf-16le' || encoding === 'utf-16') {
// LE: low byte first
if (byte2 === 0 && byte1 < 0x20 && byte1 !== 0x09 && byte1 !== 0x0A && byte1 !== 0x0D && byte1 !== 0x00) {
return false;
}
}
if (encoding === 'utf-16be' || encoding === 'utf-16') {
// BE: high byte first
if (byte1 === 0 && byte2 < 0x20 && byte2 !== 0x09 && byte2 !== 0x0A && byte2 !== 0x0D && byte2 !== 0x00) {
return false;
}
}
}
return true;
}
// Handle Latin-1 / ISO-8859-1 hints
if (encoding === 'latin1' || encoding === 'iso-8859-1') {
for (let i = 0; i < scanLength; i++) {
const byte = fileBuffer[i];
// Null byte is never valid in Latin-1 text files
if (byte === 0x00) return false;
// Control characters except TAB, LF, CR are suspicious
if (byte < 0x20 && byte !== 0x09 && byte !== 0x0A && byte !== 0x0D) {
return false;
}
// Bytes 0x80-0xFF are all valid Latin-1 characters, so no check needed
}
return true;
}
// Handle CJK encodings
if (
encoding === 'cjk' ||
encoding === 'big5' ||
encoding === 'gb2312' ||
encoding === 'gbk' ||
encoding === 'euc-kr' ||
encoding === 'shift-jis'
) {
// For CJK, we trust the user's hint and only check for definitive binary indicators
for (let i = 0; i < scanLength; i++) {
const byte = fileBuffer[i];
// Null byte is binary indicator even in CJK
if (byte === 0x00) return false;
// Control characters (except TAB, LF, CR) suggest binary
if (byte < 0x20 && byte !== 0x09 && byte !== 0x0A && byte !== 0x0D) {
return false;
}
}
return true;
}
// Unknown encoding, fall through to default behavior
return false;
}

308
node_modules/isbinaryfile/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,308 @@
import { statSync, openSync, readSync, closeSync, type Stats } from 'node:fs';
import { open, stat } from 'node:fs/promises';
import { detectUtf16NoBom, isTextWithEncodingHint } from './encoding.js';
import type { EncodingHint } from './encoding.js';
export { EncodingHint } from './encoding.js';
const MAX_BYTES: number = 512;
const UTF8_BOUNDARY_RESERVE: number = 3;
/**
* Options for binary file detection.
*/
export interface IsBinaryOptions {
/**
* Hint about expected encoding to avoid false positives.
*/
encoding?: EncodingHint;
/**
* Size of the buffer (only used when file is a Buffer).
*/
size?: number;
}
// A very basic non-exception raising reader. Read bytes and
// at the end use hasError() to check whether this worked.
class Reader {
public fileBuffer: Buffer;
public size: number;
public offset: number;
public error: boolean;
constructor(fileBuffer: Buffer, size: number) {
this.fileBuffer = fileBuffer;
this.size = size;
this.offset = 0;
this.error = false;
}
public hasError(): boolean {
return this.error;
}
public nextByte(): number {
if (this.offset === this.size || this.hasError()) {
this.error = true;
return 0xff;
}
return this.fileBuffer[this.offset++];
}
public next(len: number): number[] {
// Prevent massive array allocation by checking bounds first
if (len < 0 || len > this.size - this.offset) {
this.error = true;
return [];
}
const n = new Array();
for (let i = 0; i < len; i++) {
// Stop reading if an error occurred
if (this.error) {
return n;
}
n[i] = this.nextByte();
}
return n;
}
}
// Read a Google Protobuf var(iable)int from the buffer.
function readProtoVarInt(reader: Reader): number {
let idx = 0;
let varInt = 0;
while (!reader.hasError()) {
const b = reader.nextByte();
varInt = varInt | ((b & 0x7f) << (7 * idx));
if ((b & 0x80) === 0) {
break;
}
if (idx >= 10) {
// Varint can be between 1 and 10 bytes. This is too large.
reader.error = true;
break;
}
idx++;
}
return varInt;
}
// Attempt to taste a full Google Protobuf message.
function readProtoMessage(reader: Reader): boolean {
const varInt = readProtoVarInt(reader);
const wireType = varInt & 0x7;
switch (wireType) {
case 0:
readProtoVarInt(reader);
return true;
case 1:
reader.next(8);
return true;
case 2:
const len = readProtoVarInt(reader);
reader.next(len);
return true;
case 5:
reader.next(4);
return true;
}
return false;
}
// Check whether this seems to be a valid protobuf file.
function isBinaryProto(fileBuffer: Buffer, totalBytes: number): boolean {
const reader = new Reader(fileBuffer, totalBytes);
let numMessages = 0;
while (true) {
// Definitely not a valid protobuf
if (!readProtoMessage(reader) && !reader.hasError()) {
return false;
}
// Short read?
if (reader.hasError()) {
break;
}
numMessages++;
}
return numMessages > 0;
}
export async function isBinaryFile(file: string | Buffer, options?: IsBinaryOptions): Promise<boolean> {
if (isString(file)) {
const fileStat = await stat(file);
isStatFile(fileStat);
const fileHandle = await open(file, 'r');
try {
const allocBuffer = Buffer.alloc(MAX_BYTES + UTF8_BOUNDARY_RESERVE);
const { bytesRead } = await fileHandle.read(allocBuffer, 0, MAX_BYTES + UTF8_BOUNDARY_RESERVE, 0);
return isBinaryCheck(allocBuffer, bytesRead, options);
} finally {
await fileHandle.close();
}
} else {
const size = options?.size !== undefined ? options.size : file.length;
return isBinaryCheck(file, size, options);
}
}
export function isBinaryFileSync(file: string | Buffer, options?: IsBinaryOptions): boolean {
if (isString(file)) {
const fileStat = statSync(file);
isStatFile(fileStat);
const fileDescriptor = openSync(file, 'r');
const allocBuffer = Buffer.alloc(MAX_BYTES + UTF8_BOUNDARY_RESERVE);
const bytesRead = readSync(fileDescriptor, allocBuffer, 0, MAX_BYTES + UTF8_BOUNDARY_RESERVE, 0);
closeSync(fileDescriptor);
return isBinaryCheck(allocBuffer, bytesRead, options);
} else {
const size = options?.size !== undefined ? options.size : file.length;
return isBinaryCheck(file, size, options);
}
}
function isBinaryCheck(fileBuffer: Buffer, bytesRead: number, options?: IsBinaryOptions): boolean {
// empty file. no clue what it is.
if (bytesRead === 0) {
return false;
}
let suspiciousBytes = 0;
const totalBytes = Math.min(bytesRead, MAX_BYTES + UTF8_BOUNDARY_RESERVE);
const scanBytes = Math.min(totalBytes, MAX_BYTES);
// UTF-8 BOM
if (bytesRead >= 3 && fileBuffer[0] === 0xef && fileBuffer[1] === 0xbb && fileBuffer[2] === 0xbf) {
return false;
}
// UTF-32 BOM
if (
bytesRead >= 4 &&
fileBuffer[0] === 0x00 &&
fileBuffer[1] === 0x00 &&
fileBuffer[2] === 0xfe &&
fileBuffer[3] === 0xff
) {
return false;
}
// UTF-32 LE BOM
if (
bytesRead >= 4 &&
fileBuffer[0] === 0xff &&
fileBuffer[1] === 0xfe &&
fileBuffer[2] === 0x00 &&
fileBuffer[3] === 0x00
) {
return false;
}
// GB BOM
if (
bytesRead >= 4 &&
fileBuffer[0] === 0x84 &&
fileBuffer[1] === 0x31 &&
fileBuffer[2] === 0x95 &&
fileBuffer[3] === 0x33
) {
return false;
}
if (totalBytes >= 5 && fileBuffer.slice(0, 5).toString() === '%PDF-') {
/* PDF. This is binary. */
return true;
}
// UTF-16 BE BOM
if (bytesRead >= 2 && fileBuffer[0] === 0xfe && fileBuffer[1] === 0xff) {
return false;
}
// UTF-16 LE BOM
if (bytesRead >= 2 && fileBuffer[0] === 0xff && fileBuffer[1] === 0xfe) {
return false;
}
// Handle encoding hints - if provided, use specialized validation
if (options?.encoding) {
return !isTextWithEncodingHint(fileBuffer, bytesRead, options.encoding);
}
// Auto-detect UTF-16 without BOM by analyzing null byte patterns
const utf16Detected = detectUtf16NoBom(fileBuffer, bytesRead);
if (utf16Detected) {
// Detected UTF-16 pattern, validate as text
return !isTextWithEncodingHint(fileBuffer, bytesRead, utf16Detected);
}
for (let i = 0; i < scanBytes; i++) {
if (fileBuffer[i] === 0) {
// NULL byte--it's binary!
return true;
} else if ((fileBuffer[i] < 7 || fileBuffer[i] > 14) && (fileBuffer[i] < 32 || fileBuffer[i] > 127)) {
// UTF-8 detection
if (fileBuffer[i] >= 0xc0 && fileBuffer[i] <= 0xdf && i + 1 < totalBytes) {
i++;
if (fileBuffer[i] >= 0x80 && fileBuffer[i] <= 0xbf) {
continue;
}
} else if (fileBuffer[i] >= 0xe0 && fileBuffer[i] <= 0xef && i + 2 < totalBytes) {
i++;
if (fileBuffer[i] >= 0x80 && fileBuffer[i] <= 0xbf && fileBuffer[i + 1] >= 0x80 && fileBuffer[i + 1] <= 0xbf) {
i++;
continue;
}
} else if (fileBuffer[i] >= 0xf0 && fileBuffer[i] <= 0xf7 && i + 3 < totalBytes) {
i++;
if (
fileBuffer[i] >= 0x80 &&
fileBuffer[i] <= 0xbf &&
fileBuffer[i + 1] >= 0x80 &&
fileBuffer[i + 1] <= 0xbf &&
fileBuffer[i + 2] >= 0x80 &&
fileBuffer[i + 2] <= 0xbf
) {
i += 2;
continue;
}
}
suspiciousBytes++;
// Read at least 32 fileBuffer before making a decision
if (i >= 32 && (suspiciousBytes * 100) / scanBytes > 10) {
return true;
}
}
}
if ((suspiciousBytes * 100) / scanBytes > 10) {
return true;
}
if (suspiciousBytes > 1 && isBinaryProto(fileBuffer, scanBytes)) {
return true;
}
return false;
}
function isString(x: any): x is string {
return typeof x === 'string';
}
function isStatFile(stat: Stats): void {
if (!stat.isFile()) {
throw new Error(`Path provided was not a file!`);
}
}

297
node_modules/isbinaryfile/test/async.test.ts generated vendored Normal file
View File

@@ -0,0 +1,297 @@
import { isBinaryFile } from '../src/index';
import * as fs from 'fs';
import * as path from 'path';
const FIXTURE_PATH = './test/fixtures';
describe('async', () => {
it('does not require size if bytes are given', async () => {
const bytes = fs.readFileSync(path.join(FIXTURE_PATH, 'grep'));
expect.assertions(1);
const result = await isBinaryFile(bytes);
expect(result).toBe(true);
});
it('should return true on a binary program, accepting path', async () => {
const file = path.join(FIXTURE_PATH, 'grep');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(true);
});
it('should return true on a binary program, accepting bytes & size', async () => {
const bytes = fs.readFileSync(path.join(FIXTURE_PATH, 'grep'));
const size = fs.lstatSync(path.join(FIXTURE_PATH, 'grep')).size;
expect.assertions(1);
const result = await isBinaryFile(bytes, { size });
expect(result).toBe(true);
});
it('should return false on a extensionless script, accepting path', async () => {
const file = path.join(FIXTURE_PATH, 'perl_script');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on a extensionless script, accepting bytes & size', async () => {
const bytes = fs.readFileSync(path.join(FIXTURE_PATH, 'perl_script'));
const size = fs.lstatSync(path.join(FIXTURE_PATH, 'perl_script')).size;
expect.assertions(1);
const result = await isBinaryFile(bytes, { size });
expect(result).toBe(false);
});
it('should return false on a russian text', async () => {
const file = path.join(FIXTURE_PATH, 'russian_file.rst');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on a zero-byte image file', async () => {
const file = path.join(FIXTURE_PATH, 'null_file.gif');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return true on a gif', async () => {
const file = path.join(FIXTURE_PATH, 'trunks.gif');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(true);
});
it('should return false on some UTF8 lua file', async () => {
const file = path.join(FIXTURE_PATH, 'no.lua');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should boom on a directory', async () => {
const file = path.join(FIXTURE_PATH, 'dir');
expect.assertions(1);
await expect(isBinaryFile(file)).rejects.toThrow('Path provided was not a file!');
});
it('should boom on non-existent file', async () => {
const file = path.join(FIXTURE_PATH, 'blahblahblbahhhhhh');
expect.assertions(1);
await expect(isBinaryFile(file)).rejects.toThrow(
"ENOENT: no such file or directory, stat 'test/fixtures/blahblahblbahhhhhh'",
);
});
it('should return true on a PDF', async () => {
const file = path.join(FIXTURE_PATH, 'pdf.pdf');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(true);
});
it('should return true on a tricky PDF that needs a header check', async () => {
const file = path.join(FIXTURE_PATH, 'test.pdf');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(true);
});
it('should return false on a protobuf.proto', async () => {
const file = path.join(FIXTURE_PATH, 'protobuf.proto');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on a protobuf.proto.txt', async () => {
const file = path.join(FIXTURE_PATH, 'protobuf.proto.txt');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return true on a protobuf.proto.bin', async () => {
const file = path.join(FIXTURE_PATH, 'protobuf.proto.bin');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(true);
});
it('should not crash on malformed protobuf-like data (issue #80)', async () => {
const buff = Buffer.from(
'82ACE2828045E382805FE1828053E7828045E7878045E8838145E2988445E2948545E2828D4CE2828A44E28280418CF7EC2E',
'hex',
);
expect.assertions(1);
const result = await isBinaryFile(buff);
expect(typeof result).toBe('boolean');
});
it('should not crash on UTF-8 Chinese text buffer (issue #81)', async () => {
const chars = [
0xe9, 0xa2, 0x98, 0xe7, 0x9b, 0xae, 0x20, 0x20, 0x0a, 0xe2, 0x80, 0x9c, 0x37, 0x35, 0x35, 0x20,
0xe5, 0xb9, 0xb4, 0xe6, 0x96, 0xad, 0xe8, 0xa3, 0x82, 0xe8, 0xae, 0xba, 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 0xe4, 0xbd, 0x9c, 0xe3, 0x80, 0x81, 0xe5, 0x8d, 0xb4, 0xe5, 0xb7, 0xb2, 0xe5,
0xa4, 0xb1, 0xe7, 0x94, 0x9f, 0xe6, 0x88, 0x90, 0xe5, 0x8a, 0x9b, 0xe7, 0x9a, 0x84, 0xe2, 0x80,
0x9c, 0xe6, 0xb4, 0xbb, 0xe6, 0xad, 0xbb, 0xe4, 0xba, 0xba, 0xe5, 0xb8, 0x9d, 0xe5, 0x9b, 0xbd,
0xe2, 0x80, 0x9d, 0xe3, 0x80, 0x82, 0xe8, 0xae, 0xba, 0xe6, 0x96, 0x87, 0xe7, 0xbb, 0xbc, 0xe5,
0x90, 0x88, 0xe5, 0x8e, 0x86, 0xe5, 0x8f, 0xb2, 0xe7, 0xa4, 0xbe, 0xe4, 0xbc, 0x9a, 0xe5, 0xad,
0xa6, 0xe3, 0x80, 0x81, 0xe7, 0xb2, 0xbe, 0xe7, 0xa5, 0x9e, 0xe5, 0x88, 0x86, 0xe6, 0x9e, 0x90,
0xe4, 0xba, 0xba, 0xe7, 0xb1, 0xbb, 0xe5, 0xad, 0xa6, 0xe3, 0x80, 0x81, 0xe6, 0x94, 0xbf, 0xe6,
0xb2, 0xbb, 0xe7, 0xa5, 0x9e, 0xe5, 0xad, 0xa6, 0xe4, 0xb8, 0x8e, 0xe6, 0x96, 0xb0, 0xe5, 0x88,
0xb6, 0xe5, 0xba, 0xa6, 0xe4, 0xb8, 0xbb, 0xe4,
];
const buff = Buffer.from(chars);
expect.assertions(1);
const result = await isBinaryFile(buff);
expect(result).toBe(false);
});
it('should return false on a Vai script file', async () => {
const file = path.join(FIXTURE_PATH, 'vai_script.txt');
expect.assertions(1);
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false for non-UTF8 files', async () => {
const encodingDir = path.join(FIXTURE_PATH, 'encodings');
const files = fs.readdirSync(encodingDir);
for (const file of files) {
// Big5, GB, and Korean encodings require encoding hints to be detected as text.
// See encoding-hints.test.ts for tests with encoding hints.
if (!/big5/.test(file) && !/gb/.test(file) && !/kr/.test(file)) {
expect(await isBinaryFile(path.join(encodingDir, file))).toBe(false);
}
}
});
it('should return false on a UTF-8 file with emoji', async () => {
const file = path.join(FIXTURE_PATH, 'emoji.txt');
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 4-byte sequence truncated at byte 508', async () => {
const file = path.join(FIXTURE_PATH, '508A-4byte.txt');
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 3-byte sequence truncated at byte 509', async () => {
const file = path.join(FIXTURE_PATH, '509A-3byte.txt');
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 4-byte sequence truncated at byte 509', async () => {
const file = path.join(FIXTURE_PATH, '509A-4byte.txt');
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 2-byte sequence truncated at byte 510', async () => {
const file = path.join(FIXTURE_PATH, '510A-2byte.txt');
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 3-byte sequence truncated at byte 510', async () => {
const file = path.join(FIXTURE_PATH, '510A-3byte.txt');
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 4-byte sequence truncated at byte 510', async () => {
const file = path.join(FIXTURE_PATH, '510A-4byte.txt');
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
it('should return false on real-world Python file with UTF-8 at boundary (utf8-boundary-truncation bug case)', async () => {
const file = path.join(FIXTURE_PATH, 'utf8-boundary-truncation_case.py');
const result = await isBinaryFile(file);
expect(result).toBe(false);
});
});

114
node_modules/isbinaryfile/test/encoding-hints.test.ts generated vendored Normal file
View File

@@ -0,0 +1,114 @@
import { isBinaryFile, isBinaryFileSync } from '../src/index';
import * as fs from 'fs';
import * as path from 'path';
const FIXTURE_PATH = './test/fixtures';
const ENCODING_PATH = path.join(FIXTURE_PATH, 'encodings');
describe('encoding hints', () => {
describe('options API', () => {
it('should work with no options', () => {
const result = isBinaryFileSync(path.join(FIXTURE_PATH, 'grep'));
expect(result).toBe(true);
});
it('should work with options object containing size', () => {
const bytes = fs.readFileSync(path.join(FIXTURE_PATH, 'grep'));
const result = isBinaryFileSync(bytes, { size: bytes.length });
expect(result).toBe(true);
});
});
describe('UTF-16 without BOM', () => {
it('should auto-detect UTF-16LE without BOM as text', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'utf16le-no-bom.txt'));
expect(result).toBe(false);
});
it('should auto-detect UTF-16BE without BOM as text', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'utf16be-no-bom.txt'));
expect(result).toBe(false);
});
it('should detect UTF-16LE text with utf-16le hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'utf16le-no-bom.txt'), { encoding: 'utf-16le' });
expect(result).toBe(false);
});
it('should detect UTF-16BE text with utf-16be hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'utf16be-no-bom.txt'), { encoding: 'utf-16be' });
expect(result).toBe(false);
});
it('should detect UTF-16 text with generic utf-16 hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'utf16le-no-bom.txt'), { encoding: 'utf-16' });
expect(result).toBe(false);
});
});
describe('Latin-1 / ISO-8859-1', () => {
it('should detect test-latin.txt as text with latin1 hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'test-latin.txt'), { encoding: 'latin1' });
expect(result).toBe(false);
});
it('should detect test-latin.txt as text with iso-8859-1 hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'test-latin.txt'), { encoding: 'iso-8859-1' });
expect(result).toBe(false);
});
it('should still detect binary files as binary even with latin1 hint', () => {
const result = isBinaryFileSync(path.join(FIXTURE_PATH, 'grep'), { encoding: 'latin1' });
expect(result).toBe(true);
});
});
describe('CJK encodings', () => {
it('should detect big5.txt as text with big5 hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'big5.txt'), { encoding: 'big5' });
expect(result).toBe(false);
});
it('should detect big5_B.txt as text with big5 hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'big5_B.txt'), { encoding: 'big5' });
expect(result).toBe(false);
});
it('should detect test-gb.txt as text with gb2312 hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'test-gb.txt'), { encoding: 'gb2312' });
expect(result).toBe(false);
});
it('should detect test-gb2.txt as text with gbk hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'test-gb2.txt'), { encoding: 'gbk' });
expect(result).toBe(false);
});
it('should detect test-kr.txt as text with euc-kr hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'test-kr.txt'), { encoding: 'euc-kr' });
expect(result).toBe(false);
});
it('should detect CJK files as text with generic cjk hint', () => {
const result = isBinaryFileSync(path.join(ENCODING_PATH, 'big5.txt'), { encoding: 'cjk' });
expect(result).toBe(false);
});
it('should still detect binary files as binary even with cjk hint', () => {
const result = isBinaryFileSync(path.join(FIXTURE_PATH, 'grep'), { encoding: 'cjk' });
expect(result).toBe(true);
});
});
describe('async API with encoding hints', () => {
it('should work with async API and encoding hints', async () => {
const result = await isBinaryFile(path.join(ENCODING_PATH, 'big5.txt'), { encoding: 'big5' });
expect(result).toBe(false);
});
it('should auto-detect UTF-16 with async API', async () => {
const result = await isBinaryFile(path.join(ENCODING_PATH, 'utf16le-no-bom.txt'));
expect(result).toBe(false);
});
});
});

View File

@@ -0,0 +1 @@
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA测

View File

@@ -0,0 +1 @@
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA😀

0
node_modules/isbinaryfile/test/fixtures/dir/.gitkeep generated vendored Normal file
View File

1
node_modules/isbinaryfile/test/fixtures/emoji.txt generated vendored Normal file
View File

@@ -0,0 +1 @@
UTF-8 emoji 📦

View File

@@ -0,0 +1 @@
BIG5_TW BIG5編碼繁體中文測試

View File

@@ -0,0 +1,22 @@
OpenVPN HOWTO 中文版
作者liyi 譯 文章出處openvpn 發布時間2005-09-16 點擊3435 字體: 【小 中 大】
OpenVPN HOWTO
介紹
此文檔描述一個典型的Home到Office的通信中OpenVPN的配置。這份HOWTO舉了一個完整的配置實例在man page手冊頁中有一個更為簡單的例子。
此HOWTO文檔還有如下格式
PDF
PostScript
附加的文檔
其他的一些很好的文檔及HOWTO 為不同環境下配置OpenVPN而作。
基本的隧道(Tunnel)類型
OpenVPN可以創建兩種基本的隧道類型
Routed IP tunnels -- 適用於不需廣播的點對點IP(point-to-point)通信。比起橋接網絡隧道來略顯得更有效率些而且更易配置。此HOWTO文檔涵蓋了Routed IP tunnels。
Bridged Ethernet Tunnels(橋接網絡隧道) -- 能用於IP協議或非IP協議的隧道。這種類型的隧道更適合於使用廣播(broadcast)的應用比如某些Windows網絡游戲。配置起來稍微復雜些。關於橋接網絡隧道的Mini-HOWTO。
Routed IP tunnel HOWTO
我們會嘗試描述一個完整的系統配置期間涉及到防火牆VPNNAT以及他們彼此間的相互關聯我們不會孤立的一部分一部分的探討VPN設置。

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
UTF-8 chinese UTF8格式的中文,包含中文标点符号“”。看看能不能看清楚

View File

@@ -0,0 +1 @@
<EFBFBD><EFBFBD>ͨ

View File

@@ -0,0 +1 @@
<EFBFBD><EFBFBD>ͨͨ<EFBFBD><EFBFBD>ͨͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>

View File

@@ -0,0 +1 @@
그런데 이렇게 굳이 글을 올리고자하는 것은

View File

@@ -0,0 +1,18 @@
-*- coding: latin-1 -*-
Mit freundlichen Grüßen
mit freundlichen Grüßen
Das ist ein Äpfel.
Was können Sie jetzt machen?
Machen wir eine Übung!
Worüber?
Darüber.
Das ist euro: €
Euro: €!
µClinux

View File

@@ -0,0 +1,2 @@
ʩʦʵʫʿ,ʶʳʯʨʬʷ,ʾʷʵ,ʱʰʮʭʺʪʯʨʬ,ʼʹʯʨʬʴ,ʵʷʫ.
ʫʦʧʨʩʺʪʫʿʫʬʮʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼʽʾʫʿ

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
UTF-8 chinese UTF8格式的中文,包含中文标点符号“”。看看能不能看清楚

View File

@@ -0,0 +1 @@
中文

BIN
node_modules/isbinaryfile/test/fixtures/grep generated vendored Executable file

Binary file not shown.

2
node_modules/isbinaryfile/test/fixtures/no.lua generated vendored Normal file
View File

@@ -0,0 +1,2 @@
if table.get_length(baseObj.item_tbl) < 1 then return end

View File

BIN
node_modules/isbinaryfile/test/fixtures/pdf.pdf generated vendored Normal file

Binary file not shown.

2
node_modules/isbinaryfile/test/fixtures/perl_script generated vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/perl
print "Hello World.\n";

View File

@@ -0,0 +1,5 @@
syntax = "proto3";
message Something {
string entry = 3687091;
}

View File

@@ -0,0 +1 @@
š«ˆ^A very long string with no suspicous characters that is currently not detected as binary proto

View File

@@ -0,0 +1 @@
entry: "A very long string with no suspicous characters that is currently not detected as binary proto"

View File

@@ -0,0 +1,49 @@
Общие сведения о программном комплексе
**************************************
test
Назначение программного комплекса
=================================
Функции программного комплекса
==============================
Требования к минимальному составу аппаратных средств
====================================================
.. Сведения о средствах, обеспечивающих выполнение программы.
Требования к минимальному составу программных средств
=====================================================
.. Сведения о средствах, обеспечивающих выполнение программы.
Требования к персоналу (системному программисту)
================================================
Структура программного комплекса
********************************
.. Сведения о структуре программы, ее составных частях, о связях между
.. составными частями и о связях с другими программами.
Настройка программного комплекса
********************************
Настройка на состав технических средств
=======================================
.. Описание действий по настройке программного комплекса на условия конкретного применения.
Настройка на состав программных средств
=======================================
.. Описание действий по настройке программного комплекса на условия конкретного
.. применения.
Проверка программного комплекса
*******************************
.. Описание способов проверки, позволяющих дать общее заключение о
.. работоспособности программного комплекса (контрольные примеры, методы прогона,
.. результаты).
Сообщения системному программисту
*********************************
.. Тексты сообщений, выдаваемых в ходе выполнения настройки, проверки
.. программы, а также в ходе выполнения программы, описание их содержания и
.. действий, которые необходимо предпринять по этим сообщениям.

BIN
node_modules/isbinaryfile/test/fixtures/test.pdf generated vendored Normal file

Binary file not shown.

BIN
node_modules/isbinaryfile/test/fixtures/trunks.gif generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -0,0 +1,32 @@
"""
测试脚本 - DDD增强网络推理
只保存预测结果,不计算指
作者: Dxxx Dexxx
日期: 2025
"""
import os
import sys
import argparse
import torch
import cv2
import numpy as np
from tqdm import tqdm
from pathlib import Path
# 添加上级目录到路径
from data import DDDEnhancerDataset
def function():
"""
保存预测结果
Args:
pred: 预测结果张量 [1, H, W] 或 [H, W],值在[0, 1]
save_path: 保存路径
original_size: 原始图像尺寸 (height, width),如果提供则调整到此尺寸
"""
pass

View File

@@ -0,0 +1,3 @@
ꕢꕎꕌ ꔖꔜꕯꕊ (1) ꕉꕜꕮ ꔔꘋ ꖸ ꔰ ꗋꘋ ꕮꕨ ꔔꘋ ꖸ ꕎ ꕉꖸꕊ ꕴꖃ ꕃꔤꘂ ꗱ, ꕉꖷ ꗪꗡ ꔻꔤ ꗏꗒꗡ ꕎ ꗪ ꕉꖸꕊ ꖏꕎ. ꕉꕡ ꖏ ꗳꕮꕊ ꗏ ꕪ ꗓ ꕉꖷ ꕉꖸ ꕘꕞ ꗪ. ꖏꖷ ꕉꖸꔧ ꖏ ꖸ ꕚꕌꘂ ꗷꔤ ꕞ ꘃꖷ ꘉꔧ ꗠꖻ ꕞ ꖴꘋ ꔳꕩ ꕉꖸ ꗳ.
ꕢꕎꕌ ꗱꕞꕯꕊ (2) ꗞ ꗏꗒ ꔰ ꕚ ꖷ ꗋꖺꕒꕌ ꖸ ꔰ ꕞ ꕺꖃ ꘈꗢ ꗏ ꗷꔤ ꕞ ꘃꖷ ꗞ ꗏ ꗓꖺ ꔰ ꔇꔀ ꕉ ꕮ, ꕉꔤ ꔳ ꗞ ꔱꔤꕮ ꖏ ꖺ ꗞ ꗬꔤꕮ ꖺ ꗞ ꕺꖃ ꕮꔧ ꕮꔕ, ꕉꔤ ꔳ ꖷꖬ ꖏ ꖺ ꕪꔤ, ꕉꔤ ꕢ ꔽꔤ ꕮ ꖺ ꔵꘉ, ꖺ ꕐꕌꔳ, ꖺ ꖏ ꘀꗫ ꕃꔤ ꖺ ꗞꗢ ꗃꕎ ꕸꖃ ꖷ ꗏ ꖺ ꗞ ꖷ ꖸ ꗏ, ꕉꔤ ꔳ ꔻꔤ ꗞꖻ ꖏ ꖺ ꔌꘋ ꕴꕱ ꗞꖻ, ꕉꔤ ꕢ ꕴꖃ ꕃꔤ ꕮ ꔧ ꖏ ꕮꔕ ꗷꔤ ꔰ. ꕉꔤ ꕒꕢ ꕉ ꔫꔤ ꕞ, ꗞ ꕮ ꗞ ꖸ ꗏ ꗓꖺ ꕮꕨ ꔻꔤ ꖏ ꗱ, ꖺ ꕢꕎꕌ ꖏ ꖴꕮ ꖺ ꗷꔤ ꖷ ꖦꖕꕰꕊ ꗪ ꗞꗢ ꕞ ꕴꖃ ꕸꖃꔀ ꗱ ꗡꕯ, ꖺ ꕐꕌꔳ ꖷ ꗏ ꗞꗢ ꗃꕎ, ꕉꔤ ꔳ ꕸꖃ ꖴꘋ ꖏ, ꔧ ꗨꗡ ꕉꕌ ꕸꖃꔀ ꗪ ꕸꖃ ꕮꔕ ꗛꖺ, ꔧ ꗨꗡ ꕉꕌ ꕸꖃꔀ ꗪ ꖴꗷ ꕢꕮ ꕒꕩ ꗏ ꖺ ꗷꔤ ꕮꔕ ꔰ ꕞ.

259
node_modules/isbinaryfile/test/sync.test.ts generated vendored Normal file
View File

@@ -0,0 +1,259 @@
import { isBinaryFileSync } from '../src/index';
import * as fs from 'fs';
import * as path from 'path';
const FIXTURE_PATH = './test/fixtures';
describe('sync', () => {
it('should require size if bytes are given', () => {
const bytes = fs.readFileSync(path.join(FIXTURE_PATH, 'grep'));
const result = isBinaryFileSync(bytes);
expect(result).toBe(true);
});
it('should return true on a binary program, accepting path', () => {
const file = path.join(FIXTURE_PATH, 'grep');
const result = isBinaryFileSync(file);
expect(result).toBe(true);
});
it('should return true on a binary program, accepting bytes & size', () => {
const bytes = fs.readFileSync(path.join(FIXTURE_PATH, 'grep'));
const size = fs.lstatSync(path.join(FIXTURE_PATH, 'grep')).size;
const result = isBinaryFileSync(bytes, { size });
expect(result).toBe(true);
});
it('should return false on a extensionless script, accepting path', () => {
const file = path.join(FIXTURE_PATH, 'perl_script');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on a extensionless script, accepting bytes & size', () => {
const bytes = fs.readFileSync(path.join(FIXTURE_PATH, 'perl_script'));
const size = fs.lstatSync(path.join(FIXTURE_PATH, 'perl_script')).size;
const result = isBinaryFileSync(bytes, { size });
expect(result).toBe(false);
});
it('should return false on a russian text', () => {
const file = path.join(FIXTURE_PATH, 'russian_file.rst');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on a zero-byte image file', () => {
const file = path.join(FIXTURE_PATH, 'null_file.gif');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return true on a gif', () => {
const file = path.join(FIXTURE_PATH, 'trunks.gif');
const result = isBinaryFileSync(file);
expect(result).toBe(true);
});
it('should return false on some UTF8 lua file', () => {
const file = path.join(FIXTURE_PATH, 'no.lua');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should boom on a directory', () => {
const file = path.join(FIXTURE_PATH, 'dir');
try {
isBinaryFileSync(file);
} catch (e: any) {
expect(e.message).toBe('Path provided was not a file!');
}
});
it('should boom on non-existent file', () => {
const file = path.join(FIXTURE_PATH, 'blahblahblbahhhhhh');
try {
isBinaryFileSync(file);
} catch (e: any) {
expect(e.message).toBe("ENOENT: no such file or directory, stat 'test/fixtures/blahblahblbahhhhhh'");
}
});
it('should return true on a PDF', () => {
const file = path.join(FIXTURE_PATH, 'pdf.pdf');
const result = isBinaryFileSync(file);
expect(result).toBe(true);
});
it('should return true on a tricky PDF that needs a header check', () => {
const file = path.join(FIXTURE_PATH, 'test.pdf');
const result = isBinaryFileSync(file);
expect(result).toBe(true);
});
it('should return false for non-UTF8 files', () => {
const encodingDir = path.join(FIXTURE_PATH, 'encodings');
const files = fs.readdirSync(encodingDir);
files.forEach((file) => {
// Big5, GB, and Korean encodings require encoding hints to be detected as text.
// See encoding-hints.test.ts for tests with encoding hints.
if (!/big5/.test(file) && !/gb/.test(file) && !/kr/.test(file)) {
expect(isBinaryFileSync(path.join(encodingDir, file))).toBe(false);
}
});
});
it('should return false on a protobuf.proto', () => {
const file = path.join(FIXTURE_PATH, 'protobuf.proto');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on a protobuf.proto.txt', () => {
const file = path.join(FIXTURE_PATH, 'protobuf.proto.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return true on a protobuf.proto.bin', () => {
const file = path.join(FIXTURE_PATH, 'protobuf.proto.bin');
const result = isBinaryFileSync(file);
expect(result).toBe(true);
});
it('should return false on a Vai script file', () => {
const file = path.join(FIXTURE_PATH, 'vai_script.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should not crash on malformed protobuf-like data (issue #80)', () => {
const buff = Buffer.from(
'82ACE2828045E382805FE1828053E7828045E7878045E8838145E2988445E2948545E2828D4CE2828A44E28280418CF7EC2E',
'hex',
);
const result = isBinaryFileSync(buff);
expect(typeof result).toBe('boolean');
});
it('should not crash on UTF-8 Chinese text buffer (issue #81)', () => {
const chars = [
0xe9, 0xa2, 0x98, 0xe7, 0x9b, 0xae, 0x20, 0x20, 0x0a, 0xe2, 0x80, 0x9c, 0x37, 0x35, 0x35, 0x20,
0xe5, 0xb9, 0xb4, 0xe6, 0x96, 0xad, 0xe8, 0xa3, 0x82, 0xe8, 0xae, 0xba, 0xe2, 0x80, 0x9d, 0xef,
0xbc, 0x9a, 0xe4, 0xb8, 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 0xb4, 0xe5, 0xb7, 0xb2, 0xe5,
0xa4, 0xb1, 0xe7, 0x94, 0x9f, 0xe6, 0x88, 0x90, 0xe5, 0x8a, 0x9b, 0xe7, 0x9a, 0x84, 0xe2, 0x80,
0x9c, 0xe6, 0xb4, 0xbb, 0xe6, 0xad, 0xbb, 0xe4, 0xba, 0xba, 0xe5, 0xb8, 0x9d, 0xe5, 0x9b, 0xbd,
0xe2, 0x80, 0x9d, 0xe3, 0x80, 0x82, 0xe8, 0xae, 0xba, 0xe6, 0x96, 0x87, 0xe7, 0xbb, 0xbc, 0xe5,
0x90, 0x88, 0xe5, 0x8e, 0x86, 0xe5, 0x8f, 0xb2, 0xe7, 0xa4, 0xbe, 0xe4, 0xbc, 0x9a, 0xe5, 0xad,
0xa6, 0xe3, 0x80, 0x81, 0xe7, 0xb2, 0xbe, 0xe7, 0xa5, 0x9e, 0xe5, 0x88, 0x86, 0xe6, 0x9e, 0x90,
0xe4, 0xba, 0xba, 0xe7, 0xb1, 0xbb, 0xe5, 0xad, 0xa6, 0xe3, 0x80, 0x81, 0xe6, 0x94, 0xbf, 0xe6,
0xb2, 0xbb, 0xe7, 0xa5, 0x9e, 0xe5, 0xad, 0xa6, 0xe4, 0xb8, 0x8e, 0xe6, 0x96, 0xb0, 0xe5, 0x88,
0xb6, 0xe5, 0xba, 0xa6, 0xe4, 0xb8, 0xbb, 0xe4,
];
const buff = Buffer.from(chars);
const result = isBinaryFileSync(buff);
expect(result).toBe(false);
});
it('should return false on a UTF-8 file with emoji', () => {
const file = path.join(FIXTURE_PATH, 'emoji.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 4-byte sequence truncated at byte 508', () => {
const file = path.join(FIXTURE_PATH, '508A-4byte.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 3-byte sequence truncated at byte 509', () => {
const file = path.join(FIXTURE_PATH, '509A-3byte.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 4-byte sequence truncated at byte 509', () => {
const file = path.join(FIXTURE_PATH, '509A-4byte.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 2-byte sequence truncated at byte 510', () => {
const file = path.join(FIXTURE_PATH, '510A-2byte.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 3-byte sequence truncated at byte 510', () => {
const file = path.join(FIXTURE_PATH, '510A-3byte.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on UTF-8 file with 4-byte sequence truncated at byte 510', () => {
const file = path.join(FIXTURE_PATH, '510A-4byte.txt');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
it('should return false on real-world Python file with UTF-8 at boundary (utf8-boundary-truncation bug case)', () => {
const file = path.join(FIXTURE_PATH, 'utf8-boundary-truncation_case.py');
const result = isBinaryFileSync(file);
expect(result).toBe(false);
});
});

18
node_modules/isbinaryfile/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"declaration": true,
"outDir": "./lib",
"strict": true,
"esModuleInterop": true
},
"include": [
"src"
],
"exclude": [
"node_modules",
"**/__tests__/*"
]
}