aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-27 04:55:20 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-27 04:55:20 -0800
commit608b906bd51bfaa73ccbe835e7e278a42054f59e (patch)
treec0f00f8f21d635c64d6c47d36c4aea95e1657b37
parent09146d1c115f7307b545dae0c8cfcec2a4342322 (diff)
downloadbun-608b906bd51bfaa73ccbe835e7e278a42054f59e.tar.gz
bun-608b906bd51bfaa73ccbe835e7e278a42054f59e.tar.zst
bun-608b906bd51bfaa73ccbe835e7e278a42054f59e.zip
[JSON] Use UTF-8 JSON parser when it's not for JavaScript
-rw-r--r--src/cli/create_command.zig2
-rw-r--r--src/cli/upgrade_command.zig2
-rw-r--r--src/install/install.zig4
-rw-r--r--src/install/lockfile.zig2
-rw-r--r--src/install/npm.zig2
5 files changed, 6 insertions, 6 deletions
diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig
index ab370bf3b..008ed2ef2 100644
--- a/src/cli/create_command.zig
+++ b/src/cli/create_command.zig
@@ -31,7 +31,7 @@ const fs = @import("../fs.zig");
const URL = @import("../query_string_map.zig").URL;
const HTTP = @import("http");
const NetworkThread = HTTP.NetworkThread;
-const ParseJSON = @import("../json_parser.zig").ParseJSON;
+const ParseJSON = @import("../json_parser.zig").ParseJSONUTF8;
const Archive = @import("../libarchive/libarchive.zig").Archive;
const Zlib = @import("../zlib.zig");
const JSPrinter = @import("../js_printer.zig");
diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig
index b7a1a086f..5995be9c2 100644
--- a/src/cli/upgrade_command.zig
+++ b/src/cli/upgrade_command.zig
@@ -29,7 +29,7 @@ const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
const fs = @import("../fs.zig");
const URL = @import("../query_string_map.zig").URL;
const HTTP = @import("http");
-const ParseJSON = @import("../json_parser.zig").ParseJSON;
+const ParseJSON = @import("../json_parser.zig").ParseJSONUTF8;
const Archive = @import("../libarchive/libarchive.zig").Archive;
const Zlib = @import("../zlib.zig");
const JSPrinter = @import("../js_printer.zig");
diff --git a/src/install/install.zig b/src/install/install.zig
index 371a2948d..377844990 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -3778,7 +3778,7 @@ pub const PackageManager = struct {
);
initializeStore();
- var current_package_json = json_parser.ParseJSON(&package_json_source, ctx.log, manager.allocator) catch |err| {
+ var current_package_json = json_parser.ParseJSONUTF8(&package_json_source, ctx.log, manager.allocator) catch |err| {
if (Output.enable_ansi_colors) {
ctx.log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {};
} else {
@@ -3921,7 +3921,7 @@ pub const PackageManager = struct {
// Now, we _re_ parse our in-memory edited package.json
// so we can commit the version we changed from the lockfile
- current_package_json = json_parser.ParseJSON(&source, ctx.log, manager.allocator) catch |err| {
+ current_package_json = json_parser.ParseJSONUTF8(&source, ctx.log, manager.allocator) catch |err| {
Output.prettyErrorln("<red>error<r><d>:<r> package.json failed to parse due to error {s}", .{@errorName(err)});
Output.flush();
Global.exit(1);
diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig
index 835298372..85e82e5a9 100644
--- a/src/install/lockfile.zig
+++ b/src/install/lockfile.zig
@@ -2203,7 +2203,7 @@ pub const Package = extern struct {
// A valid package.json always has "{}" characters
if (source.contents.len < 2) return error.InvalidPackageJSON;
- var json = json_parser.ParseJSON(&source, log, allocator) catch |err| {
+ var json = json_parser.ParseJSONUTF8(&source, log, allocator) catch |err| {
if (Output.enable_ansi_colors) {
log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {};
} else {
diff --git a/src/install/npm.zig b/src/install/npm.zig
index d5122c001..44cf0d4ed 100644
--- a/src/install/npm.zig
+++ b/src/install/npm.zig
@@ -756,7 +756,7 @@ pub const PackageManifest = struct {
) !?PackageManifest {
const source = logger.Source.initPathString(expected_name, json_buffer);
initializeStore();
- const json = json_parser.ParseJSON(&source, log, allocator) catch return null;
+ const json = json_parser.ParseJSONUTF8(&source, log, allocator) catch return null;
if (json.asProperty("error")) |error_q| {
if (error_q.expr.asString(allocator)) |err| {