File: redirect_query_string.t

package info (click to toggle)
libcgi-pm-perl 4.68-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,028 kB
  • sloc: perl: 6,082; makefile: 9
file content (72 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!perl

use strict;
use warnings;

use Test::More 'no_plan';
use CGI;

# monkey patching to make testing easier
no warnings 'once';
no warnings 'redefine';
*CGI::read_multipart_related = sub {};
*CGI::save_request           = sub {};

my $q_string = 'foo=bar';

$ENV{REQUEST_METHOD} = 'POST';
$ENV{CONTENT_TYPE}   = 'multipart/related;boundary="------- =A; start=X';

{
    $ENV{QUERY_STRING}   = $q_string;
    my $q = CGI->new;
    is( $q->query_string,$q_string,'query_string' );
}

{
    $ENV{REDIRECT_QUERY_STRING}
        = delete( $ENV{QUERY_STRING} );

    my $q = CGI->new;
    is( $q->query_string,$q_string,'query_string (redirect)' );
}

{
    $ENV{REDIRECT_REDIRECT_QUERY_STRING}
        = delete( $ENV{REDIRECT_QUERY_STRING} );

    my $q = CGI->new;
    is( $q->query_string,$q_string,'query_string (redirect x 2)' );
}

{
    $ENV{REDIRECT_REDIRECT_REDIRECT_QUERY_STRING}
        = delete( $ENV{REDIRECT_REDIRECT_QUERY_STRING} );

    my $q = CGI->new;
    is( $q->query_string,$q_string,'query_string (redirect x 3)' );
}

{
    $ENV{REDIRECT_REDIRECT_REDIRECT_REDIRECT_QUERY_STRING}
        = delete( $ENV{REDIRECT_REDIRECT_REDIRECT_QUERY_STRING} );

    my $q = CGI->new;
    is( $q->query_string,$q_string,'query_string (redirect x 4)' );
}

{
    $ENV{REDIRECT_REDIRECT_REDIRECT_REDIRECT_REDIRECT_QUERY_STRING}
        = delete( $ENV{REDIRECT_REDIRECT_REDIRECT_REDIRECT_QUERY_STRING} );

    my $q = CGI->new;
    is( $q->query_string,$q_string,'query_string (redirect x 5)' );
}

{
    $ENV{REDIRECT_REDIRECT_REDIRECT_REDIRECT_REDIRECT_REDIRECT_QUERY_STRING}
        = delete( $ENV{REDIRECT_REDIRECT_REDIRECT_REDIRECT_REDIRECT_QUERY_STRING} );

    my $q = CGI->new;
    is( $q->query_string,'','no more than 5 redirects supported' );
}