@@ -83,22 +83,22 @@ my $max_output_len = 290;
83
83
sub run {
84
84
my ($program , $executer , $ename ) = @_ ;
85
85
if ($program =~ / ^https:\/\/ gist\. github\. com\/ [^\/ ]+?\/ (\p{HexDigit} +)$ / ) {
86
- my $page = ` curl -s https://api.github.com/gists/\Q $1 \E ` ;
87
- my $json = decode_json $page ;
88
- if ($json -> {message } && $json -> {message } eq ' Not Found' ) {
89
- return ' gist not found' ;
90
- } else {
91
- $program = (values %{$json -> {files }})[0]{content };
92
- }
86
+ my $page = ` curl -s https://api.github.com/gists/\Q $1 \E ` ;
87
+ my $json = decode_json $page ;
88
+ if ($json -> {message } && $json -> {message } eq ' Not Found' ) {
89
+ return ' gist not found' ;
90
+ } else {
91
+ $program = (values %{$json -> {files }})[0]{content };
92
+ }
93
93
} elsif ($program =~ / ^https:\/\/ github\. com\/ ([^\/ ]+\/ [^\/ ]+)\/ blob\/ ([^\/ ]+\/ [^\/ ].*)$ / ) {
94
- my ($project , $file ) = ($1 , $2 );
95
- my $page = ` curl -s \Q $program \E ` ;
96
- if ($page =~ / href="\/ $project \/ raw\/ $file "/ ) {
97
- $program
98
- = decode_utf8 ` curl -s \Q https://raw.github.com/$project /$file \E ` ;
99
- } else {
100
- return ' file not found'
101
- };
94
+ my ($project , $file ) = ($1 , $2 );
95
+ my $page = ` curl -s \Q $program \E ` ;
96
+ if ($page =~ / href="\/ $project \/ raw\/ $file "/ ) {
97
+ $program
98
+ = decode_utf8 ` curl -s \Q https://raw.github.com/$project /$file \E ` ;
99
+ } else {
100
+ return ' file not found'
101
+ }
102
102
} elsif ($program =~ / ^https:\/\/ bitbucket.org\/ snippets\/ ([^\/ ]+)\/ ([^\/ ]+)$ / ) {
103
103
my $page = ` curl -s https://bitbucket.org/!api/2.0/snippets/\Q $1 \E /\Q $2 \E ` ;
104
104
my $json = decode_json $page ;
@@ -129,7 +129,7 @@ sub _fork_and_eval {
129
129
_auto_execute($executer , $program , $fh , $filename , $ename );
130
130
} else {
131
131
# server
132
- alarm 22;
132
+ alarm 22;
133
133
local $SIG {ALRM } = sub {
134
134
$timed_out = 1;
135
135
kill 15, -$fork_val ;
@@ -146,7 +146,7 @@ sub _fork_and_eval {
146
146
my $result = do { local $/ ; <$fh > };
147
147
unlink $filename or warn " couldn't delete '$filename ': $! " ;
148
148
if ($timed_out ) {
149
- $result = " (timeout)" . $result ;
149
+ $result = " (timeout)" . $result ;
150
150
} elsif ($? & 127) {
151
151
$result = " (signal " . (split ' ' , $Config {sig_name })[$? ] . " )" . $result ;
152
152
}
0 commit comments