This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update CGI to CPAN version 3.62
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Sat, 10 Nov 2012 12:31:46 +0000 (12:31 +0000)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Sat, 10 Nov 2012 12:31:46 +0000 (12:31 +0000)
  [DELTA]

  Version 3.62, Nov 9th, 2012

    [INTERNALS]
    - Changed how the  deprecated endform function was defined for compatibilty
      with the development version of Perl.
    - Fix failures in t/tmpdir.t when run as root
      https://github.com/markstos/CGI.pm/issues/22, RT#80659)

    - Made it possible to force a sorted order for things like hash
      attributes so that tests are not dependent on a particular hash
      ordering. This will be required in modern perls which will
      change the ordering per process. (Yves, RT#80659)

Porting/Maintainers.pl
cpan/CGI/Changes
cpan/CGI/lib/CGI.pm
cpan/CGI/lib/CGI/Util.pm
cpan/CGI/t/autoescape.t
cpan/CGI/t/function.t
cpan/CGI/t/html.t
cpan/CGI/t/tmpdir.t

index 3241378..ca97d64 100755 (executable)
@@ -343,7 +343,7 @@ use File::Glob qw(:case);
 
     'CGI' => {
         'MAINTAINER'   => 'lstein',
-        'DISTRIBUTION' => 'MARKSTOS/CGI.pm-3.61.tar.gz',
+        'DISTRIBUTION' => 'MARKSTOS/CGI.pm-3.62.tar.gz',
         'FILES'        => q[cpan/CGI],
         'EXCLUDED'     => [
             qw( cgi_docs.html
index de312d9..52f1d02 100644 (file)
@@ -1,3 +1,17 @@
+
+Version 3.62, Nov 9th, 2012
+
+    [INTERNALS]
+    - Changed how the  deprecated endform function was defined for compatibilty
+      with the development version of Perl. 
+    - Fix failures in t/tmpdir.t when run as root
+      https://github.com/markstos/CGI.pm/issues/22, RT#80659)
+
+    - Made it possible to force a sorted order for things like hash
+      attributes so that tests are not dependent on a particular hash
+      ordering. This will be required in modern perls which will
+      change the ordering per process. (Yves, RT#80659)
+
 Version 3.61 Nov 2nd, 2012
 
   (No code changes)
index 8a6cca0..d8d91f4 100644 (file)
@@ -20,7 +20,7 @@ use Carp 'croak';
 
 # The revision is no longer being updated since moving to git. 
 $CGI::revision = '$Id: CGI.pm,v 1.266 2009/07/30 16:32:34 lstein Exp $';
-$CGI::VERSION='3.61';
+$CGI::VERSION='3.62';
 
 # HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES.
 # UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING.
@@ -129,10 +129,6 @@ sub initialize_globals {
 
 # ------------------ START OF THE LIBRARY ------------
 
-#### Method: endform
-# This method is DEPRECATED
-*endform = \&end_form;
-
 # make mod_perlhappy
 initialize_globals();
 
@@ -1960,6 +1956,7 @@ END_OF_FUNC
 
 #### Method: end_form
 # End a form
+# Note: This repeated below under the older name.
 'end_form' => <<'END_OF_FUNC',
 sub end_form {
     my($self,@p) = self_or_default(@_);
@@ -1976,6 +1973,22 @@ sub end_form {
 }
 END_OF_FUNC
 
+'endform' => <<'END_OF_FUNC',
+sub endform {
+    my($self,@p) = self_or_default(@_);
+    if ( $NOSTICKY ) {
+        return wantarray ? ("</form>") : "\n</form>";
+    } else {
+        if (my @fields = $self->get_fields) {
+            return wantarray ? ("<div>",@fields,"</div>","</form>")
+                             : "<div>".(join '',@fields)."</div>\n</form>";
+        } else {
+            return "</form>";
+        }
+    }
+}
+END_OF_FUNC
+
 #### Method: end_multipart_form
 # end a multipart form
 'end_multipart_form' => <<'END_OF_FUNC',
index b059281..494560e 100644 (file)
@@ -1,15 +1,19 @@
 package CGI::Util;
+use base 'Exporter';
 require 5.008001;
 use strict;
-require Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(rearrange rearrange_header make_attributes unescape escape 
-               expires ebcdic2ascii ascii2ebcdic);
+our @EXPORT_OK = qw(rearrange rearrange_header make_attributes unescape escape
+        expires ebcdic2ascii ascii2ebcdic);
 
-our $VERSION = '3.53';
+our $VERSION = '3.62';
 
 use constant EBCDIC => "\t" ne "\011";
 
+# This option is not documented and may change or go away.
+# The HTML spec does not require attributes to be sorted,
+# but it's useful for testing to get a predictable order back.
+our $SORT_ATTRIBUTES;
+
 # (ord('^') == 95) for codepage 1047 as on os390, vmesa
 our @A2E = (
    0,  1,  2,  3, 55, 45, 46, 47, 22,  5, 21, 11, 12, 13, 14, 15,
@@ -28,7 +32,7 @@ our @A2E = (
  172,105,237,238,235,239,236,191,128,253,254,251,252,186,174, 89,
   68, 69, 66, 70, 67, 71,156, 72, 84, 81, 82, 83, 88, 85, 86, 87,
  140, 73,205,206,203,207,204,225,112,221,222,219,220,141,142,223
-        );
+     );
 our @E2A = (
    0,  1,  2,  3,156,  9,134,127,151,141,142, 11, 12, 13, 14, 15,
   16, 17, 18, 19,157, 10,  8,135, 24, 25,146,143, 28, 29, 30, 31,
@@ -46,7 +50,7 @@ our @E2A = (
  125, 74, 75, 76, 77, 78, 79, 80, 81, 82,185,251,252,249,250,255,
   92,247, 83, 84, 85, 86, 87, 88, 89, 90,178,212,214,210,211,213,
   48, 49, 50, 51, 52, 53, 54, 55, 56, 57,179,219,220,217,218,159
-        );
+     );
 
 if (EBCDIC && ord('^') == 106) { # as in the BS2000 posix-bc coded character set
      $A2E[91] = 187;   $A2E[92] = 188;  $A2E[94] = 106;  $A2E[96] = 74;
@@ -77,7 +81,7 @@ sub rearrange {
     my ($order,@param) = @_;
     my ($result, $leftover) = _rearrange_params( $order, @param );
     push @$result, make_attributes( $leftover, defined $CGI::Q ? $CGI::Q->{escape} : 1 ) 
-       if keys %$leftover;
+    if keys %$leftover;
     @$result;
 }
 
@@ -95,30 +99,30 @@ sub _rearrange_params {
     return [] unless @param;
 
     if (ref($param[0]) eq 'HASH') {
-       @param = %{$param[0]};
+    @param = %{$param[0]};
     } else {
-       return \@param 
-           unless (defined($param[0]) && substr($param[0],0,1) eq '-');
+    return \@param 
+        unless (defined($param[0]) && substr($param[0],0,1) eq '-');
     }
 
     # map parameters into positional indices
     my ($i,%pos);
     $i = 0;
     foreach (@$order) {
-       foreach (ref($_) eq 'ARRAY' ? @$_ : $_) { $pos{lc($_)} = $i; }
-       $i++;
+    foreach (ref($_) eq 'ARRAY' ? @$_ : $_) { $pos{lc($_)} = $i; }
+    $i++;
     }
 
     my (@result,%leftover);
     $#result = $#$order;  # preextend
     while (@param) {
-       my $key = lc(shift(@param));
-       $key =~ s/^\-//;
-       if (exists $pos{$key}) {
-           $result[$pos{$key}] = shift(@param);
-       } else {
-           $leftover{$key} = shift(@param);
-       }
+    my $key = lc(shift(@param));
+    $key =~ s/^\-//;
+    if (exists $pos{$key}) {
+        $result[$pos{$key}] = shift(@param);
+    } else {
+        $leftover{$key} = shift(@param);
+    }
     }
 
     return \@result, \%leftover;
@@ -132,18 +136,22 @@ sub make_attributes {
 
     my $quote = $do_not_quote ? '' : '"';
 
+    my @attr_keys= keys %$attr;
+    if ($SORT_ATTRIBUTES) {
+        @attr_keys= sort @attr_keys;
+    }
     my(@att);
-    foreach (keys %{$attr}) {
-       my($key) = $_;
-       $key=~s/^\-//;     # get rid of initial - if present
+    foreach (@attr_keys) {
+    my($key) = $_;
+    $key=~s/^\-//;     # get rid of initial - if present
 
-       # old way: breaks EBCDIC!
-       # $key=~tr/A-Z_/a-z-/; # parameters are lower case, use dashes
+    # old way: breaks EBCDIC!
+    # $key=~tr/A-Z_/a-z-/; # parameters are lower case, use dashes
 
-       ($key="\L$key") =~ tr/_/-/; # parameters are lower case, use dashes
+    ($key="\L$key") =~ tr/_/-/; # parameters are lower case, use dashes
 
-       my $value = $escape ? simple_escape($attr->{$_}) : $attr->{$_};
-       push(@att,defined($attr->{$_}) ? qq/$key=$quote$value$quote/ : qq/$key/);
+    my $value = $escape ? simple_escape($attr->{$_}) : $attr->{$_};
+    push(@att,defined($attr->{$_}) ? qq/$key=$quote$value$quote/ : qq/$key/);
     }
     return @att;
 }
@@ -176,19 +184,19 @@ sub unescape {
     if (EBCDIC) {
       $todecode =~ s/%([0-9a-fA-F]{2})/chr $A2E[hex($1)]/ge;
     } else {
-       # handle surrogate pairs first -- dankogai. Ref: http://unicode.org/faq/utf_bom.html#utf16-2
-       $todecode =~ s{
-                       %u([Dd][89a-bA-B][0-9a-fA-F]{2}) # hi
-                       %u([Dd][c-fC-F][0-9a-fA-F]{2})   # lo
-                     }{
-                         utf8_chr(
-                                  0x10000 
-                                  + (hex($1) - 0xD800) * 0x400 
-                                  + (hex($2) - 0xDC00)
-                                 )
-                     }gex;
+    # handle surrogate pairs first -- dankogai. Ref: http://unicode.org/faq/utf_bom.html#utf16-2
+    $todecode =~ s{
+            %u([Dd][89a-bA-B][0-9a-fA-F]{2}) # hi
+                %u([Dd][c-fC-F][0-9a-fA-F]{2})   # lo
+              }{
+              utf8_chr(
+                   0x10000 
+                   + (hex($1) - 0xD800) * 0x400 
+                   + (hex($2) - 0xDC00)
+                  )
+              }gex;
       $todecode =~ s/%(?:([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/
-       defined($1)? chr hex($1) : utf8_chr(hex($2))/ge;
+    defined($1)? chr hex($1) : utf8_chr(hex($2))/ge;
     }
   return $todecode;
 }
index 4117298..3a25c2d 100644 (file)
@@ -6,6 +6,7 @@ use warnings;
 use Test::More tests => 18;
 
 use CGI qw/ autoEscape escapeHTML button textfield password_field textarea popup_menu scrolling_list checkbox_group optgroup checkbox radio_group submit image_button button /;
+$CGI::Util::SORT_ATTRIBUTES = 1;
 
 is (button(-name => 'test<'), '<input type="button"  name="test&lt;" value="test&lt;" />', "autoEscape defaults to On");
 
index e0c0845..a15c010 100644 (file)
@@ -5,6 +5,7 @@ END {print "not ok 1\n" unless $loaded;}
 use Config;
 use CGI (':standard','keywords');
 $loaded = 1;
+$CGI::Util::SORT_ATTRIBUTES = 1;
 print "ok 1\n";
 
 ######################### End of black magic.
@@ -103,4 +104,4 @@ test(30, !charset("") && header() eq "Content-Type: text/html${CRLF}${CRLF}", "E
 
 test(31, header(-foo=>'bar') eq "Foo: bar${CRLF}Content-Type: text/html${CRLF}${CRLF}", "Custom header");
 
-test(32, start_form(-action=>'one',name=>'two',onsubmit=>'three') eq qq(<form method="post" action="one" enctype="multipart/form-data" onsubmit="three" name="two">), "initial dash followed by undashed arguments");
+test(32, start_form(-action=>'one',name=>'two',onsubmit=>'three') eq qq(<form method="post" action="one" enctype="multipart/form-data" name="two" onsubmit="three">), "initial dash followed by undashed arguments")
index 09a3e33..efa2f03 100644 (file)
@@ -5,6 +5,7 @@ use Test::More tests => 33;
 END { ok $loaded; }
 use CGI ( ':standard', '-no_debug', '*h3', 'start_table' );
 $loaded = 1;
+$CGI::Util::SORT_ATTRIBUTES= 1;
 ok 1;
 
 BEGIN {
@@ -98,7 +99,7 @@ is start_html(
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
 <head>
 <title>The world of foo</title>
-<script src="foo.js" charset="utf-8" type="text/javascript"></script>
+<script charset="utf-8" src="foo.js" type="text/javascript"></script>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 </head>
 <body>
index 717cd8c..cf9d716 100644 (file)
@@ -1,7 +1,11 @@
 #!perl
-use Test::More tests => 9;
+use Test::More;
 use strict;
 
+if( $> == 0 ) {
+    plan skip_all => "Root can write to 'unwritable files', so many of these tests don't make sense for root.";
+}
+
 my ($testdir, $testdir2);
 
 BEGIN {
@@ -34,4 +38,6 @@ isnt($CGITempFile::TMPDIRECTORY, $testdir2,
 isnt($CGITempFile::TMPDIRECTORY, $testdir,
     "unwritable \$ENV{TMPDIR} not overridden with an unwritable \$CGITempFile::TMPDIRECTORY");
 
+done_testing();
+
 END { for ($testdir, $testdir2) { chmod 0700, $_; rmdir; } }