Skip to content

Commit

Permalink
dl_zerobin redirect to dl_privatebin
Browse files Browse the repository at this point in the history
This makes the default handler work with both sites...again.

Did I seriously spend *two hours* debugging PrivateBin decompression
failures last week, even though I had already done the exact same thing
in 2017? Yes, apparently I did.
  • Loading branch information
grawity committed Jul 15, 2019
1 parent 4450f53 commit 948ed96
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion getpaste
Original file line number Diff line number Diff line change
Expand Up @@ -962,21 +962,29 @@ sub dl_zerobin {
}

my $body = get($url) // return;
if ($body =~ /\bprivatebin\.js/) {
# recent PrivateBin versions have a different API
_debug("redirecting to PrivateBin handler");
goto &dl_privatebin;
}
$body =~ m{<div id="cipherdata"[^>]*>(.+)</div>} || return;
my $data = decode_html($1);
$data = decode_json($data);
if (ref $data eq "ARRAY") {
# early ZeroBin
$data = $data->[0]->{data};
$data = unwrap_sjcl($data, $frag);
$data = decode_base64($data);
$data = decompress_deflate($data);
} else {
# later ZeroBin and early PrivateBin
$data = $data->{data};
$data = decode_json($data);
$data = unwrap_sjcl($data, $frag);
$data = decode_base64($data);
if ($body =~ /\bPrivateBin\b/) {
$data = decode("UTF-8", $data);
# (see comment in dl_privatebin)
$data = decode("utf-8", $data);
}
$data = decompress_deflate($data);
}
Expand Down

0 comments on commit 948ed96

Please sign in to comment.