summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Lozano <walter.lozano@collabora.com>2021-06-17 19:27:12 +0000
committerWalter Lozano <walter.lozano@collabora.com>2021-06-18 22:19:20 +0000
commit765de9763ff33634c88970bb3e9ce52de040c9ba (patch)
tree78e16a26207b0535c53dd8a0ba15d506a3083a2c
parent4d04a7cd6ae48671bf308eb075a6ae1b258f76e9 (diff)
Fix parsing package.json file with UTF-8
Currently when parsing info from package.json into a json object non ASCII chars are not handling correctly leading to an error: "malformed UTF-8 character in JSON string" Fix the issue by using from_json instead of decode_json. Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
-rw-r--r--lib/Dpkg/Copyright/Scanner.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Dpkg/Copyright/Scanner.pm b/lib/Dpkg/Copyright/Scanner.pm
index 581dd1b0..da58fe74 100644
--- a/lib/Dpkg/Copyright/Scanner.pm
+++ b/lib/Dpkg/Copyright/Scanner.pm
@@ -301,7 +301,7 @@ my $__extract_nodejs_info = sub ($c_key, $l_key, $file, $c, $l, $current_dir) {
my $json_file = $current_dir->child($file);
if ($json_file->is_file) {
- my $data = decode_json($json_file->slurp_utf8);
+ my $data = from_json($json_file->slurp_utf8);
my @c_data;
if (ref $data->{$c_key}) {
@@ -329,7 +329,7 @@ my $__extract_json_info = sub ($c_key, $l_key, $file, $c, $l, $current_dir) {
my $json_file = $current_dir->child($file);
if ($json_file->is_file) {
- my $data = decode_json($json_file->slurp_utf8);
+ my $data = from_json($json_file->slurp_utf8);
my @c_data = ref $data->{$c_key} ? $data->{$c_key}->@* : $data->{$c_key};
my @l_data = ref $data->{$l_key} ? $data->{$l_key}->@* : $data->{$l_key};
return (join("\n ", @c_data) || $c, join(" or ",@l_data) || $l);