From c1f23c578881b85ae79b524a60160d8f4fb7151b Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Sat, 8 Jun 2024 18:36:13 +0200 Subject: fix(ext/node): lossy UTF-8 read node_modules files (#24140) Previously various reads of files in `node_modules` would error on invalid UTF-8. These were cases involving: - reading package.json from Rust - reading package.json from JS - reading CommonJS files from JS - reading CommonJS files from Rust (for ESM translation) - reading ESM files from Rust --- ext/node/package_json.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/node/package_json.rs') diff --git a/ext/node/package_json.rs b/ext/node/package_json.rs index adae7d634..a19a2d64d 100644 --- a/ext/node/package_json.rs +++ b/ext/node/package_json.rs @@ -82,7 +82,7 @@ impl PackageJson { return Ok(CACHE.with(|cache| cache.borrow()[&path].clone())); } - let source = match fs.read_text_file_sync(&path, None) { + let source = match fs.read_text_file_lossy_sync(&path, None) { Ok(source) => source, Err(err) if err.kind() == ErrorKind::NotFound => { return Ok(Rc::new(PackageJson::empty(path))); -- cgit v1.2.3