# $0 - the text to be encoded
# $1 - the regexp which specifies which characters should be encoded
# if not specified then a default regexp is used
+# @_HT_ENCODE is a function which will perform HTML entity encoding
+# $0 - the text to be encoded
+# $1 - the regexp which specifies which characters should be encoded
+# if not specified then a default regexp is used
# @_SPRINTF is a call to the Perl sprintf() function
# $0 - the format string
# $1 and continuing - the parameters to sprintf()
use constant ESCAPE => '_ESCAPE';
use constant URL_ENCODE => '_URL_ENCODE';
+use constant HT_ENCODE => '_HT_ENCODE';
use constant PATH => '_PATH';
use constant SPRINTF => '_SPRINTF';
return $outcome;
}
+# NOT UNICODE AWARE
sub urlencode {
(my $text, my $match) = @_;
unless (defined $match) {
return $outcome;
}
+# NOT UNICODE AWARE
+# (but there no real need to escaping non-ascii characters)
+sub entityencode {
+ (my $text, my $match) = @_;
+ unless (defined $match) {
+ $match = '[\"=><\&]'
+ }
+
+ my $outcome = '';
+ foreach my $ch (split('', $text)) {
+ if ($ch =~ $match) {
+ $outcome .= sprintf('&#%02hu;',ord($ch));
+ }
+ else {
+ $outcome .= $ch;
+ }
+ }
+ return $outcome;
+}
+
sub join_path {
(my $joiner, my @segments) = @_;
elsif ($name eq URL_ENCODE) {
$return = urlencode(@parameter_list);
}
+ elsif ($name eq HT_ENCODE) {
+ $return = entityencode(@parameter_list);
+ }
elsif ($name eq PATH) {
$return = join_path($cfg{PATH_SEPARATOR()},@parameter_list);
}
if ($to_parse =~ /^((([^#\\])|(\\.))*)#/) {
$to_parse = $1;
}
- if ($to_parse =~ /^[ \t]*([^ \t](.*[^ \t])?)[ \t]*$/) {
+ if ($to_parse =~ /^[ \t]*(([^ \t](.*[^ \t])?)?)[ \t]*$/) {
$to_parse = $1;
}