Mail Index


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ApacheGallery] Fw: modules/gallery/lib/Apache (Gallery.pm): Provide our own, perhaps not broken, version of uri_escape



Hi Michael,
Yup, it seems to work just fine. Thanks!
Will now retrofit my work to it.
Paul
----- Original Message -----
From: "Michael Legart" <[email protected]>
To: <[email protected]>
Sent: Saturday, March 09, 2002 6:57 AM
Subject: [ApacheGallery] Fw: modules/gallery/lib/Apache (Gallery.pm):
Provide our own, perhaps not broken, version of uri_escape


> Hi,
>
> Paul - can you test to see if this works on perl 5.6.0?
>
> ----- Forwarded message from CVS-mil <[email protected]> -----
>
> From: CVS-mil <[email protected]>
> Subject: modules/gallery/lib/Apache (Gallery.pm): Provide our own, perhaps
not broken, version of uri_escape
> To: [email protected]
> Date: 9 Mar 2002 11:55:59 -0000
>
> -----------------
> --     Log     --
> -----------------
>
> Modified Files:
> Gallery.pm
> Log Message:
> Provide our own, perhaps not broken, version of uri_escape
>
>
> -----------------
> --   Changes   --
> -----------------
>
> Index: modules/gallery/lib/Apache/Gallery.pm
> diff -u modules/gallery/lib/Apache/Gallery.pm:1.72
modules/gallery/lib/Apache/Gallery.pm:1.73
> --- modules/gallery/lib/Apache/Gallery.pm:1.72 Thu Feb 28 16:56:02 2002
> +++ modules/gallery/lib/Apache/Gallery.pm Sat Mar  9 12:55:57 2002
> @@ -1,6 +1,6 @@
>  package Apache::Gallery;
>
> -# $Id: Gallery.pm,v 1.72 2002/02/28 15:56:02 mil Exp $
> +# $Id: Gallery.pm,v 1.73 2002/03/09 11:55:57 mil Exp $
>
>  use 5.006;
>  use strict;
> @@ -17,11 +17,11 @@
>  use Image::Info qw(image_info);
>  use Image::Size qw(imgsize);
>  use CGI::FastTemplate;
> -use URI::Escape;
>  use File::stat;
>  use POSIX qw(floor);
> +use Carp;
>
> -my $escape_rule = '^a-zA-Z0-9\/_\\.';
> +my $escape_rule = "^A-Za-z0-9\-_.!~*'()\/";
>
>  use Inline C => Config =>
>   LIBS => '-L/usr/X11R6/lib -lImlib2 -lttf -lm -ldl -lXext -lXext',
> @@ -599,6 +599,31 @@
>   }
>
>   return $menu;
> +}
> +
> +
> +# Because of some problems with bugs in URI::Escape in perl 5.6.0
> +# we include our own version here for now.
> +my %escapes;
> +# Build a char->hex map
> +for (0..255) {
> + $escapes{chr($_)} = sprintf("%%%02X", $_);
> +}
> +my %subst; # compiled patterns (cached)
> +sub uri_escape {
> +
> + my ($text, $pattern) = @_;
> + return undef unless defined $text;
> +
> + unless (exists $subst{$pattern}) {
> + (my $tmp = $pattern) =~ s,/,[^\]\\/,g;
> + $subst{$pattern} =
> + eval "sub {\$_[0] =~ s/([$tmp])/\$escapes{\$1}/g; }";
> + Carp::croak("uri_escape: [email protected]") if [email protected];
> + }
> + &{$subst{$pattern}}($text);
> +
> + return $text;
>  }
>
>  1;
>
> ----- End forwarded message -----
>
> ---------------------------------------------------------------------
> Apache::Gallery users mailinglist. http://apachegallery.dk/
> To unsubscribe, e-mail: [email protected]
>
>
>


---------------------------------------------------------------------
Apache::Gallery users mailinglist. http://apachegallery.dk/
To unsubscribe, e-mail: [email protected]