Skip to content

Commit

Permalink
dpaste needs all entities to be decoded
Browse files Browse the repository at this point in the history
Most other decoders only scrape basic JSON or Base64 out of tags, this
one scrapes raw content.
  • Loading branch information
grawity committed Dec 15, 2020
1 parent 6b34743 commit 5c4f922
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions getpaste
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ sub decode_html {
return $str;
}

sub decode_html_harder {
my ($str) = @_;

eval {
require HTML::Entities
} or _die("missing Perl package 'HTML::Entities'");

return HTML::Entities::decode_entities($str);
}

sub try_decode_json {
my ($data) = @_;

Expand Down Expand Up @@ -870,7 +880,7 @@ sub dl_defuse {

if ($body =~ m{<textarea id="paste"[^>]*>(.+?)</textarea>}) {
my $data = $1;
$data = decode_html($data);
$data = decode_html_harder($data);
return $data;
}

Expand Down Expand Up @@ -912,7 +922,7 @@ sub dl_dpaste {

my $body = get($url);
if ($body =~ m{<textarea id="copySnippetSource">(.+?)</textarea>}s) {
return decode_html($1);
return decode_html_harder($1);
}
return;
}
Expand Down

0 comments on commit 5c4f922

Please sign in to comment.