module Cwd not used in PLP; don't use
[perl/plp/.git] / PLP / Functions.pm
index debb7675c698983bad696cfb9440feba95abdd75..ef5b311070ec6c35744169a9cd9cf79160144f91 100644 (file)
@@ -1,6 +1,5 @@
-#-------------------------#
-  package PLP::Functions;
-#-------------------------#
+package PLP::Functions;
+
 use base 'Exporter';
 use Fcntl qw(:flock);
 use strict;
@@ -16,7 +15,7 @@ sub Include ($) {
     local $@;
     eval 'package PLP::Script; ' . PLP::source($PLP::file, 0, join ' ', (caller)[2,1]);
     if ($@) {
-       PLP::Functions::exit if $@ =~ /\cS\cT\cO\cP/;
+       PLP::Functions::exit() if $@ =~ /\cS\cT\cO\cP/;
        PLP::error($@, 1);
     }
 }
@@ -67,9 +66,9 @@ sub Entity (@) {
     return defined wantarray ? (wantarray ? @$ref : "@$ref") : undef;
 }
 
-# Browsers do s/ /+/ - I don't care about RFC's, but I do care about real-life
-# situations.
 sub DecodeURI (@) {
+    # Browsers do s/ /+/ - I don't care about RFC's, but I do care about real-life
+    # situations.
     my @r;
     local $_;    
     for (@_) {
@@ -85,6 +84,7 @@ sub DecodeURI (@) {
     }
     return defined wantarray ? (wantarray ? @r : "@r") : undef;
 }
+
 sub EncodeURI (@) {
     my @r;
     local $_;
@@ -253,17 +253,26 @@ In void context, B<changes> the values of the given variables. In other contexts
 
     <: print Entity($user_input); :>
 
+Be warned that this function also HTMLizes consecutive whitespace and newlines (using &nbsp; and <br> respectively).
+For simple escaping, use L<XML::Quote>. To escape high-bit characters as well, use L<HTML::Entities>.
+
 =item EncodeURI LIST
 
-Replaces characters by their %-encoded values.
+Encodes URI strings according to RFC 3986. All disallowed characters are replaced by their %-encoded values.
 
 In void context, B<changes> the values of the given variables. In other contexts, returns the changed versions.
 
     <a href="/foo.plp?name=<:= EncodeURI($name) :>">Link</a>
 
+Note that the following reserved characters are I<not> percent-encoded, even though they may have a special meaning in URIs:
+
+       / ? : @ $
+
+This should be safe for escaping query values (as in the example above), but it may be a better idea to use L<URI::Escape> instead.
+
 =item DecodeURI LIST
 
-Decodes %-encoded strings.
+Decodes %-encoded strings. Unlike L<URI::Escape>, it also translates + characters to spaces (as browsers use those).
 
 In void context, B<changes> the values of the given variables. In other contexts, returns the changed versions.
 
@@ -299,5 +308,7 @@ Adds a Set-Cookie header. STRING must be a valid Set-Cookie header value.
 
 Juerd Waalboer <juerd@cpan.org>
 
+Current maintainer: Mischa POSLAWSKY <shiar@cpan.org>
+
 =cut