retain undef in encoding functions
[perl/plp/.git] / lib / PLP / Functions.pm
index 90ff741453c213954362315a335d5579c1446515..627d39071d0e99e15da7212e6c5d44965130794d 100644 (file)
@@ -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;
                };
@@ -75,7 +78,7 @@ sub EncodeURI (@) {
 
 sub AddCookie ($) {
        if ($PLP::Script::header{'Set-Cookie'}) {
-               $PLP::Script::header{'Set-Cookie'} .= "\nSet-Cookie: $_[0]";
+               $PLP::Script::header{'Set-Cookie'} .= "\n" . $_[0];
        } else {
                $PLP::Script::header{'Set-Cookie'} = $_[0];
        }