Skip to content

Commit

Permalink
no longer apply js-deflate workaround if not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
grawity committed Jun 11, 2020
1 parent c0b86b7 commit 087f1ab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions getpaste
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,8 @@ sub dl_privatebin {
my $body = get($url) // return;
$body = decode_json($body);

if ($body->{v} == 2) {
if ($body->{v} && $body->{v} == 2) {
_trace("redirecting to v2 unwrapper");
my $data = $body;
$data = unwrap_privatebin_v2($data, $frag);
return $data;
Expand All @@ -1005,7 +1006,13 @@ sub dl_privatebin {
$data = decode_base64($data);
# The example code that comes with js-deflate mistakenly encodes binary
# data as UTF-8, and of course PrivateBin just used it verbatim.
$data = encode("latin1", decode("utf-8", $data));
# 2020-06-11: Apparently they changed to no longer use deflate.
if (eval {decode("utf-8", $data, &Encode::FB_CROAK)}) {
_trace("working around js-deflate binary data bug");
$data = encode("latin1", decode("utf-8", $data));
} else {
_trace("skipping js-deflate workaround");
}
$data = decompress_deflate($data);
return $data;
}
Expand Down

0 comments on commit 087f1ab

Please sign in to comment.