Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to import a module because of invalid utf8 sequence #23911

Closed
sigmaSd opened this issue May 21, 2024 · 3 comments · Fixed by denoland/deno_graph#483
Closed

fails to import a module because of invalid utf8 sequence #23911

sigmaSd opened this issue May 21, 2024 · 3 comments · Fixed by denoland/deno_graph#483

Comments

@sigmaSd
Copy link
Contributor

sigmaSd commented May 21, 2024

Version: Deno 1.43.5

import {} from "npm:js-clipper@1.0.1";

error: Unable to load /home/mrcool/.cache/deno/npm/registry.npmjs.org/js-clipper/1.0.1/clipper.js imported from file:///home/mrcool/dev/deno/lab/fffz/b.ts

Caused by:
    invalid utf-8 sequence of 1 bytes from index 165105

The problematic character is in line 5955 of clipper.js

@sigmaSd
Copy link
Contributor Author

sigmaSd commented May 21, 2024

reduced case
a.js

// ł

deno run a.js # invalid data

@sigmaSd
Copy link
Contributor Author

sigmaSd commented May 22, 2024

to create the corrupted file you can use this script (in case copy/pasting messes the character)

Deno.writeFileSync("./cc.js", new Uint8Array([47, 47, 32, 197, 10]));

it fails here https://github.com/denoland/deno/blob/main/cli/module_loader.rs#L174

@sigmaSd
Copy link
Contributor Author

sigmaSd commented May 22, 2024

I pinpointed the problem to https://github.com/denoland/deno_graph/blob/main/src/source/mod.rs#L725
the reproduction code is simply utf16 but deno assumes its utf8
bun and node detect it correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant