Skip to content

Commit 81b9834

Browse files
committed
Remove the check_url method.
The server really should not be checking urls in this way. If an invalid url is given, let the error come out in the browser. This is the correct way to deal with this.
1 parent a9af123 commit 81b9834

File tree

4 files changed

+3
-45
lines changed

4 files changed

+3
-45
lines changed

lib/PGalias.pm

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ sub alias_for_html {
310310
if ( $aux_file_id =~ /https?:/ ) { #external link_file
311311
$resource_object->uri($aux_file_id); #no unique id is needed -- external link doc
312312
$resource_object->{copy_link}->{type} = 'external';
313-
$resource_object->{uri}->{is_accessible} = $self->check_url($resource_object->uri());
313+
$resource_object->{uri}{is_accessible} = 1; # Assume a url is accessible.
314314
return $resource_object->uri; # external links need no further processing
315315
} elsif ( $aux_file_id =~ m|^/|) {
316316
$file_path = $aux_file_id;
@@ -383,7 +383,6 @@ sub alias_for_html {
383383
# Return full url to image file (resource_id)
384384
################################################################################
385385

386-
# $self->debug_message("link created --alias_for_image_html: url is ".$resource_object->uri(). " check =".$self->check_url($resource_object->uri()) );
387386
$resource_object->uri(); # return the uri of the resource -- in this case the URL for the file in the temp directory
388387
}
389388

@@ -457,7 +456,7 @@ sub alias_for_tex {
457456
if ( $aux_file_id =~ /https?:/ ) { # external link_file
458457
$resource_object->uri($aux_file_id); #no unique id is needed -- external link doc
459458
$resource_object->{copy_link}->{type} = 'external';
460-
$resource_object->{uri}->{is_accessible} = $self->check_url($resource_object->uri());
459+
$resource_object->{uri}{is_accessible} = 1; # Assume a url is accessible.
461460
return $resource_object->uri; # external links need no further processing
462461
} elsif ( $aux_file_id =~ m|^/|) {
463462
$file_path = $aux_file_id;
@@ -585,7 +584,7 @@ sub create_link_to_tmp_file {
585584
$resource_object->{path}->{is_accessible} = (-r $linkPath);
586585

587586
$resource_object->uri($resource_uri);
588-
$resource_object->{uri}->{is_accessible} = $self->check_url($resource_object->uri());
587+
$resource_object->{uri}{is_accessible} = 1; # Assume a url is accessible.
589588
$resource_object->{path}->{is_complete} = 1;
590589
$resource_object->{uri}->{is_complete} = 1;
591590
} else {
@@ -659,8 +658,6 @@ sub convert_file_to_png_for_tex {
659658
our ($macrosPath,
660659
# ^variable my $pwd
661660
$pwd,
662-
# ^variable my $server_root_url
663-
$server_root_url,
664661
);
665662

666663
# ^function findMacroFile
@@ -692,34 +689,6 @@ sub find_file_in_directories {
692689
return; # no file found
693690
}
694691

695-
696-
# ^function check_url
697-
# ^uses %envir
698-
sub check_url {
699-
my $self = shift;
700-
my $url = shift;
701-
my $OK_CONSTANT = "200 OK";
702-
return undef if $url =~ /;/; # make sure we can't get a second command in the url
703-
return undef unless $url =~/\S/;
704-
#FIXME -- check for other exploits of the system call #FIXME -- ALARM feature so that the response cannot be held up for too long.
705-
#ALARM: /opt/local/bin/lwp-request -d -t 40 -mHEAD ";
706-
# the -t 40 means the call times out after 40 seconds.
707-
# Set this alarm in site.conf
708-
#FIXME doesn't seem to work with relative addresses.
709-
#FIXME Can we get the machine name of the server?
710-
$server_root_url=$self->envir("server_root_url");
711-
$self->warning_message("check_url: server_root_url is not defined in site.conf") unless $server_root_url;
712-
unless ($url =~ /^http/ ) {
713-
# $self->debug_message("check_url: augmenting url $url");
714-
$url = "$server_root_url/$url";
715-
716-
}
717-
my $check_url_command = WeBWorK::PG::IO::externalCommand('checkurl');
718-
my $response = `$check_url_command $url`;
719-
# $self->debug_message("check_url: response for url $url is $response");
720-
return ($response =~ /$OK_CONSTANT/) ? 1 : 0;
721-
}
722-
723692
# This is a stub for deprecated problems that call this method. Some of the Geogebra problems that do so actually work
724693
# even though this method fails.
725694
sub findAppletCodebase {

lib/PGloadfiles.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ sub new {
9191
envir => $envir,
9292
macroFileList => {}, # records macros used in compilation
9393
pgFileName => '', # current pg file being processed
94-
server_root_url => '', # how do we find this?
9594
macrosPath => '',
9695
pwd => '', # current directory -- defined in initialize
9796
};

lib/WeBWorK/PG.pm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ sub defineProblemEnvironment ($pg_envir, $options = {}, $image_generator = undef
272272
tempDirectory => $options->{tempDirectory} // "$pg_envir->{directories}{html_temp}/",
273273
tempURL => $options->{tempURL} // "$pg_envir->{URLs}{tempURL}/",
274274
localHelpURL => $options->{localHelpURL} // "$pg_envir->{URLs}{localHelpURL}/",
275-
server_root_url => $options->{server_root_url} || '',
276275

277276
# Other things ...
278277

@@ -520,11 +519,6 @@ Public html address of the tempDirectory above.
520519
521520
Public html address for the PG help files.
522521
523-
=item server_root_url (string, default: '')
524-
525-
Server root url. This is used by check_url when verifying that static resources
526-
are available. It is prepended to relative urls in this check.
527-
528522
=item use_site_prefix (string, default: '')
529523
530524
Site prefix prepended to image and video url's inserted into problems by the

macros/PG.pl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,6 @@ sub findMacroFile {
649649
$PG->{PG_alias}->findMacroFile(@_);
650650
}
651651

652-
sub check_url {
653-
$PG->{PG_alias}->check_url(@_);
654-
}
655-
656652
sub findAppletCodebase {
657653
my $appletName = shift;
658654
my $url = eval{$PG->{PG_alias}->findAppletCodebase($appletName)};

0 commit comments

Comments
 (0)