retain undef in encoding functions
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 31 May 2008 21:23:38 +0000 (21:23 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 31 May 2008 21:34:52 +0000 (21:34 +0000)
Entity(), DecodeURI(), and EncodeURI() should return undef for any
undefined input.  Only string behaviour was specified, so users relying
on this did so at their own risk (and they can always disable warnings
like the careless bitches they are :P).

Not too coincidently also silences warnings in PLP::Functions itself.

Changes
lib/PLP/Functions.pm

diff --git a/Changes b/Changes
index da4c3e25d4b21f6c9c54770123def242d140b3c5..b0bd0b95442c5dabe4b6d5d3bc0aa6c737480eeb 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,4 +1,5 @@
 - Fix everything() wrapper (broke pre-3.20 CGI scripts on 3.20)
+- Encoding functions retain undef
 - Add charset to Content-Type header for UTF-8 output
 - Test pod coverage
 - %header values containing newlines will be sent as multiple fields
index f3621671470603b3f04f3dc086c57b22ca9ca09b..627d39071d0e99e15da7212e6c5d44965130794d 100644 (file)
@@ -38,6 +38,7 @@ sub PLP_END (&) {
 sub Entity (@) {
        my $ref = defined wantarray ? [@_] : \@_;
        for (@$ref) {
+               defined or next;
                eval {
                        s/&/&amp;/g;
                        s/"/&quot;/g;
@@ -54,6 +55,7 @@ sub Entity (@) {
 sub DecodeURI (@) {
        my $ref = defined wantarray ? [@_] : \@_;
        for (@$ref) {
+               defined or next;
                eval {
                        tr/+/ /;  # Browsers do tr/ /+/ - I don't care about RFCs, but
                                  # I do care about real-life situations.
@@ -66,6 +68,7 @@ sub DecodeURI (@) {
 sub EncodeURI (@) {
        my $ref = defined wantarray ? [@_] : \@_;
        for (@$ref) {
+               defined or next;
                eval {
                        s{([^A-Za-z0-9\-_.!~*'()/?:@\$,])}{sprintf("%%%02x", ord $1)}ge;
                };