Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Fixing URL parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
arlake228 committed Sep 19, 2022
1 parent ce9229b commit 463e1d9
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions cgi-bin/graphData.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,17 @@ sub get_ma_data {

}

# Make sure the URL looks like an esmond URL -- starts with http or https and looks like
# http://host/esmond/perfsonar/archive/[something]
# this should be url encoded
if ( $url =~ m|^https?://[^/]+/esmond/perfsonar/archive| ) {
# Force the URL to a path of /esmond/perfsonar/archive/
my $url_obj = new URI($url);
$url_obj->path('/esmond/perfsonar/archive/');
#check for https or https - actually checked by is_web_url, but also check here.
if($url_obj->scheme eq 'http' || $url_obj->scheme eq 'https'){
$url = "$url_obj";
# perform http GET on the URL
my $res = send_http_request(connection_type => 'GET',
url => $url,
timeout => 60
);

url => $url,
timeout => 60
);
# success
if ( $res->is_success ) {
print $cgi->header('application/json');
Expand All @@ -202,11 +203,9 @@ sub get_ma_data {
#error($res->message, $res->code);
}
} else {
# url does not appear to be a valid esmond archive
warn "URL is not a valid esmond archive: $url";
error("URL is not a valid esmond archive");
error("URL must be http or https", 400);
}

}

sub get_data {
Expand Down

0 comments on commit 463e1d9

Please sign in to comment.