On Jun 27, 4:27 am, brian.d....@gmail.com (brian d foy) wrote:
> > I suggest one of:
> > * Document escape and unescape in perldoc CGI (please, please,
> > please!)
> > * Elaborate on how this escaping and unescaping can be achieved using
> > only the documented interface
>
> Patches welcome :)
CC: Lincoln D. Stein, author of CGI.pm
Yeah, as soon as I hit "Send" I realized that was a very probable
repsonse :-) Ok, so here goes. Also available at http://pastebin.com/bPRq0Nsj
in case Google Groups mangles or does line wrapping:
--- orig.CGI.pm 2010-01-29 15:41:54.000000000 +0100
+++ CGI.pm 2010-06-28 08:56:49.000000000 +0200
@@ -255,6 +255,7 @@
':html' => [qw/:html2 :html3 :html4 :netscape/],
':standard' => [qw/:html2 :html3 :html4 :form :cgi/],
':push' => [qw/multipart_init multipart_start multipart_end
multipart_final/],
+ ':escape' => [qw/escape unescape/],
':all' => [qw/:html2 :html3 :netscape :form :cgi :internal :html4/]
);
@@ -4878,6 +4879,10 @@
Import all HTML-generating shortcuts (i.e. 'html2', 'html3', 'html4'
and 'netscape')
+=item B<:escape>
+
+Import the escape and unescape methods
+
=item B<:standard>
Import "standard" features, 'html2', 'html3', 'html4', 'form' and
'cgi'.
@@ -5698,6 +5703,20 @@
),
hr;
+=head2 ESCAPING/ENCODING AND UNESCAPING/DECODING URL STRINGS
+
+URL parameters are encoded in what is also known as Percent-encoding
+L<http://en.wikipedia.org/wiki/Percent-encoding>
+
+ use CGI ':escape';
+ my $string = "Hello World";
+ my $escaped = escape($string);
+ print $escaped, "\n";
+ die "How could unescape(escape($string)) ne $string"
+ unless unescape($escaped) eq $string;
+
+prints out "Hello%20World"
+
=head2 PROVIDING ARGUMENTS TO HTML SHORTCUTS
The HTML methods will accept zero, one or multiple arguments. If you
Peter
> > I suggest one of:
> > * Document escape and unescape in perldoc CGI (please, please,
> > please!)
> > * Elaborate on how this escaping and unescaping can be achieved using
> > only the documented interface
>
> Patches welcome :)
CC: Lincoln D. Stein, author of CGI.pm
Yeah, as soon as I hit "Send" I realized that was a very probable
repsonse :-) Ok, so here goes. Also available at http://pastebin.com/bPRq0Nsj
in case Google Groups mangles or does line wrapping:
--- orig.CGI.pm 2010-01-29 15:41:54.000000000 +0100
+++ CGI.pm 2010-06-28 08:56:49.000000000 +0200
@@ -255,6 +255,7 @@
':html' => [qw/:html2 :html3 :html4 :netscape/],
':standard' => [qw/:html2 :html3 :html4 :form :cgi/],
':push' => [qw/multipart_init multipart_start multipart_end
multipart_final/],
+ ':escape' => [qw/escape unescape/],
':all' => [qw/:html2 :html3 :netscape :form :cgi :internal :html4/]
);
@@ -4878,6 +4879,10 @@
Import all HTML-generating shortcuts (i.e. 'html2', 'html3', 'html4'
and 'netscape')
+=item B<:escape>
+
+Import the escape and unescape methods
+
=item B<:standard>
Import "standard" features, 'html2', 'html3', 'html4', 'form' and
'cgi'.
@@ -5698,6 +5703,20 @@
),
hr;
+=head2 ESCAPING/ENCODING AND UNESCAPING/DECODING URL STRINGS
+
+URL parameters are encoded in what is also known as Percent-encoding
+L<http://en.wikipedia.org/wiki/Percent-encoding>
+
+ use CGI ':escape';
+ my $string = "Hello World";
+ my $escaped = escape($string);
+ print $escaped, "\n";
+ die "How could unescape(escape($string)) ne $string"
+ unless unescape($escaped) eq $string;
+
+prints out "Hello%20World"
+
=head2 PROVIDING ARGUMENTS TO HTML SHORTCUTS
The HTML methods will accept zero, one or multiple arguments. If you
Peter