Skip to content

Commit b6ecb65

Browse files
committed
Allow Bitbucket snippets
The regex is not very restrictive, but it's just like other regexes in the code.
1 parent 45d27f7 commit b6ecb65

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/EvalbotExecuter.pm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ sub run {
9999
} else {
100100
return 'file not found'
101101
};
102+
} elsif ($program =~ /^https:\/\/bitbucket.org\/snippets\/([^\/]+)\/([^\/]+)$/) {
103+
my $page = `curl -s https://bitbucket.org/!api/2.0/snippets/\Q$1\E/\Q$2\E`;
104+
my $json = decode_json $page;
105+
if ($json->{error}) {
106+
return 'snippet not found';
107+
} else {
108+
my $raw_link = (values %{$json->{files}})[0]{links}->{self}->{href};
109+
$program = `curl -s \Q$raw_link\E`;
110+
}
102111
}
103112
return _fork_and_eval($program, $executer, $ename);
104113
}

0 commit comments

Comments
 (0)