From bf97d6375e0ac171005faabb0e75653318075276 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 31 May 2008 21:23:38 +0000 Subject: [PATCH] retain undef in encoding functions 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 | 1 + lib/PLP/Functions.pm | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Changes b/Changes index da4c3e2..b0bd0b9 100644 --- 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 diff --git a/lib/PLP/Functions.pm b/lib/PLP/Functions.pm index f362167..627d390 100644 --- a/lib/PLP/Functions.pm +++ b/lib/PLP/Functions.pm @@ -38,6 +38,7 @@ sub PLP_END (&) { sub Entity (@) { my $ref = defined wantarray ? [@_] : \@_; for (@$ref) { + defined or next; eval { s/&/&/g; s/"/"/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; }; -- 2.30.0