View | Details | Raw Unified | Return to bug 31250
Collapse All | Expand All

(-)a/Koha/CookieManager.pm (-1 / +5 lines)
Lines 101-107 sub clear_unless { Link Here
101
        }
101
        }
102
        next if !$name;
102
        next if !$name;
103
103
104
        if( !$self->{_remove_unless}->{$name} ) {
104
        # Try stripping _\d+ from name for cookiea like catalogue_editor_123
105
        my $stripped_name = $name;
106
        $stripped_name =~ s/_\d+$/_/;
107
108
        if( !$self->{_remove_unless}->{$stripped_name} && !$self->{_remove_unless}->{$name} ) {
105
            next if $seen->{$name};
109
            next if $seen->{$name};
106
            push @rv, CGI::Cookie->new(
110
            push @rv, CGI::Cookie->new(
107
                # -expires explicitly omitted to create shortlived 'session' cookie
111
                # -expires explicitly omitted to create shortlived 'session' cookie
(-)a/t/CookieManager.t (-2 / +15 lines)
Lines 41-47 subtest 'new' => sub { Link Here
41
};
41
};
42
42
43
subtest 'clear_unless' => sub {
43
subtest 'clear_unless' => sub {
44
    plan tests => 15;
44
    plan tests => 16;
45
45
46
    t::lib::Mocks::mock_config( Koha::CookieManager::DENY_LIST_VAR, [ 'aap', 'noot' ] );
46
    t::lib::Mocks::mock_config( Koha::CookieManager::DENY_LIST_VAR, [ 'aap', 'noot' ] );
47
47
Lines 73-78 subtest 'clear_unless' => sub { Link Here
73
    is( $rv[4]->value, q{}, 'zus empty' );
73
    is( $rv[4]->value, q{}, 'zus empty' );
74
    is( $rv[1]->httponly, 0, 'cleared wim is not httponly' );
74
    is( $rv[1]->httponly, 0, 'cleared wim is not httponly' );
75
    is( $rv[2]->httponly, 1, 'aap httponly' );
75
    is( $rv[2]->httponly, 1, 'aap httponly' );
76
77
    # Test with _123 prefix
78
    t::lib::Mocks::mock_config( Koha::CookieManager::DENY_LIST_VAR, [ 'catalogue_editor_' ] );
79
    $cmgr = Koha::CookieManager->new;
80
    $cookie1 = $q->cookie( -name => 'catalogue_editor_234', -value => '1', -expires => '+1y' );
81
    $cookie2 = $q->cookie( -name => 'catalogue_editor_345', -value => '1', -expires => '+1y' );
82
    $cookie3 = $q->cookie( -name => 'catalogue_editor_', -value => '1', -expires => '+1y' );
83
    $cookie4 = $q->cookie( -name => 'catalogue_editor', -value => '1', -expires => '+1y' );
84
85
    $list = [ $cookie1, $cookie2, $cookie3, $cookie4 ];
86
    @rv = @{$cmgr->clear_unless( @$list )};
87
    is_deeply( [ map { $_->value ? $_->name : () } @rv ],
88
        [ 'catalogue_editor_234', 'catalogue_editor_345', 'catalogue_editor_' ],
89
        'Only cookie4 should have been cleared' );
76
};
90
};
77
91
78
subtest 'replace_in_list' => sub {
92
subtest 'replace_in_list' => sub {
79
- 

Return to bug 31250