CGI

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    - change BUILD_REQUIRES to TEST_REQUIRES in Makefile.PL as these are test
      dependencies not build dependencies (GH #159)

    [ DOCUMENTATION ]
    - replace any remaining uses of indirect object notation (new Object) with
      the safer Object->new syntax (GH #156)

4.10 2014-11-27

    [ SPEC / BUG FIXES ]
    - favour -content-type arg in header if -type and -charset options are also
      passed in (GH #155, thanks to kaoru for the test case). this change also
      sorts the hash keys in the rearrange method in CGI::Util meaning the order
      of the arrangement will always be the same for params that have multiple
      aliases. really you shouldn't be passing in multiple aliases, but this will
      make it consistent should you do that

    [ DOCUMENTATION ]
    - fix some typos

4.09 2014-10-21

Changes  view on Meta::CPAN

       scripts!

  Version 2.43

    1. Fixed problem with "use strict" and file uploads (thanks to Peter
       Haworth)
    2. Fixed problem with not MSIE 3.01 for the power_mac not doing file
       uploads right.
    3. Fixed problem with file upload on IIS 4.0 when authorization in
       use.
    4. -content_type and '-content-type' can now be provided to header()
       as synonyms for -type.
    5. CGI::Carp now escapes the ampersand BEFORE escaping the > and <
       signs.
    6. Fixed "not an array reference" error when passing a hash reference
       to radio_group().
    7. Fixed non-removal of uploaded TMP files on NT platforms which
       occurs when server runs on non-C drive (thanks to Steve Kilbane
       for finding this one).

  Version 2.42

lib/CGI.pm  view on Meta::CPAN

	    # Some people want to have their cake and eat it too!
	    # Set $APPEND_QUERY_STRING = 1 to have the contents of the query string
	    # APPENDED to the POST data.
	    $query_string .= (length($query_string) ? '&' : '') . $ENV{'QUERY_STRING'} if defined $ENV{'QUERY_STRING'};
	  }
	  last METHOD;
      } 

      # Process XForms postings. We know that we have XForms in the
      # following cases:
      # method eq 'POST' && content-type eq 'application/xml'
      # method eq 'POST' && content-type =~ /multipart\/related.+start=/
      # There are more cases, actually, but for now, we don't support other
      # methods for XForm posts.
      # In a XForm POST, the QUERY_STRING is parsed normally.
      # If the content-type is 'application/xml', we just set the param
      # XForms:Model (referring to the xml syntax) param containing the
      # unparsed XML data.
      # In the case of multipart/related we set XForms:Model as above, but
      # the other parts are available as uploads with the Content-ID as the
      # the key.
      # See the URL below for XForms specs on this issue.
      # http://www.w3.org/TR/2006/REC-xforms-20060314/slice11.html#submit-options
      if ($meth eq 'POST' && defined($ENV{'CONTENT_TYPE'})) {
              if ($ENV{'CONTENT_TYPE'} eq 'application/xml') {
                      my($param) = 'XForms:Model';

lib/CGI/Carp.pm  view on Meta::CPAN

If fatalsToBrowser in conjunction with set_message does not provide 
you with all of the functionality you need, you can go one step 
further by specifying a function to be executed any time a script
calls "die", has a syntax error, or dies unexpectedly at runtime
with a line like "undef->explode();". 

    use CGI::Carp qw(set_die_handler);
    BEGIN {
       sub handle_errors {
          my $msg = shift;
          print "content-type: text/html\n\n";
          print "<h1>Oh gosh</h1>";
          print "<p>Got an error: $msg</p>";

          #proceed to send an email to a system administrator,
          #write a detailed message to the browser and/or a log,
          #etc....
      }
      set_die_handler(\&handle_errors);
    }

t/charset.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More 'no_plan';

use CGI;

my $q = CGI->new;

like( $q->header
    , qr/charset=ISO-8859-1/, "charset ISO-8859-1 is set by default for default content-type");
like( $q->header('application/json')
    , qr/charset=ISO-8859-1/, "charset ISO-8859-1 is set by default for application/json content-type");

{
    $q->charset('UTF-8');
    my $out = $q->header('text/plain');
    like($out, qr{Content-Type: text/plain; charset=UTF-8}, "setting charset alters header of text/plain");
}
{
    $q->charset('UTF-8');
    my $out = $q->header('application/json');
    like($out, qr{Content-Type: application/json; charset=UTF-8}, "setting charset alters header of application/json");

t/gh-155.t  view on Meta::CPAN

use Test::More;

use CGI;

for (1 .. 20) {
    my $q = CGI->new;

    my %args = (
        '-charset'      => 'UTF-8',
        '-type'         => 'text/html',
        '-content-type' => 'text/html; charset=iso-8859-1',
    );

    like(
		$q->header(%args),
		qr!Content-Type: text/html; charset=iso-8859-1!,
		'favour content type over charset/type'
	);
}

done_testing();

t/util.t  view on Meta::CPAN

    my $cgi_unescape = unescape("AbC\%$punct{$_}dEF");
    is($unescape, $cgi_unescape , "# $unescape ne $cgi_unescape");
}

# rearrange should return things in a consistent order, so when we pass through
# a hash reference it should sort the keys
for ( 1 .. 20 ) {
	my %args = (
		'-charset'      => 'UTF-8',
		'-type'         => 'text/html',
		'-content-type' => 'text/html; charset=iso-8859-1',
	);

	my @ordered = rearrange(
		[
			[ 'TYPE','CONTENT_TYPE','CONTENT-TYPE' ],
			'STATUS',
			[ 'COOKIE','COOKIES','SET-COOKIE' ],
			'TARGET',
			'EXPIRES',
			'NPH',



( run in 2.173 seconds using v1.01-cache-2.11-cpan-524268b4103 )