access.c: access.1.c configure.pl settings
$(PL) configure.pl settings <access.1.c >access.c
-
+
access: access.c
$(CC) $(CF) -o access access.c
#use warnings;
###LIB;
-use proxy_lib qw(urldecode divideurl urldiv2path getcgi formatheader access);
+use proxy_lib qw(urldecode divideurl entityencode urldiv2path getcgi formatheader access);
use POSIX qw(strftime);
###UNLOCK_LOG;
print '</head><body>';
print '<h1>Unlock the proxy</h1>';
if($message ne ''){
- print $message;
+ print '<p>'.entityencode($message).'</p>';
}
print '<form method="post" action="'.UNLOCK_PROXY_URL_S.'">';
print '<b>Username: </b><input type="text" name="username"><br>';
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">';
print '<html lang="en"><head>';
if($title ne ''){
- print "<title>$title</title>";
+ print '<title>'.entityencode($title).'</title>';
}
print '<meta http-equiv="Content-type" content="text/html; charset=UTF-8">';
print '</head><body>';
if($title ne ''){
- print "<h1>$title</h1>";
+ print '<h1>'.entityencode($title).'</h1>';
}
if($message ne ''){
- print $message;
+ print '<p>'.entityencode($message).'</p>';
}
print "</body></html>\n";
}
$VERSION = 0.000004;\r
@ISA = qw(Exporter);\r
@EXPORT = ();\r
-@EXPORT_OK = qw(access divideurl entitydecode formatheader getcgi joinurl path2url url2path path2urldiv readconfigfile readheaderfile urldecode urldiv2path);\r
+@EXPORT_OK = qw(access divideurl entitydecode entityencode formatheader getcgi joinurl path2url url2path path2urldiv readconfigfile readheaderfile urlencode urldecode urldiv2path);\r
%EXPORT_TAGS = ();\r
\r
# This function checks if the user has unlocked the proxy. Nonzero means yes.\r
return $t;\r
}\r
\r
+# function to encode entities, decimal, \r
+sub entityencode {\r
+ (my $t, my $all) = @_;\r
+ if ($all) {\r
+ $t =~ s/(.)/sprintf('\&#%02hu;',ord($1))/eg;\r
+ }\r
+ else {\r
+ $t =~ s/([\"=><\&])/sprintf('&#%02hu;',ord($1))/eg;\r
+ }\r
+ return $t;\r
+}\r
+\r
+sub urlencode {\r
+ (my $t, my $all) = @_;\r
+ if ($all) {\r
+ $t =~ s/(.)/sprintf('%%%02hX',ord($1))/eg;\r
+ }\r
+ else {\r
+ $t =~ s/([^0-9A-Za-z.~\-_])/sprintf('%%%02hX',ord($1))/eg;\r
+ }\r
+ return $t;\r
+}\r
+\r
# Function for decoding one html entity, called from entitydecode().\r
sub entitydecode1ch {\r
my $t = $_[0];\r