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

(-)a/Koha/Patron.pm (+7 lines)
Lines 30-35 use C4::Auth qw( checkpw_hash ); Link Here
30
use C4::Context;
30
use C4::Context;
31
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages );
31
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages );
32
use C4::Log qw( logaction );
32
use C4::Log qw( logaction );
33
use C4::Scrubber;
33
use Koha::Account;
34
use Koha::Account;
34
use Koha::ArticleRequests;
35
use Koha::ArticleRequests;
35
use Koha::AuthUtils;
36
use Koha::AuthUtils;
Lines 231-236 sub store { Link Here
231
                if defined $self->relationship
232
                if defined $self->relationship
232
                and $self->relationship eq "";
233
                and $self->relationship eq "";
233
234
235
            for my $note_field ( qw( borrowernotes opacnote ) ) {
236
                if ( !$self->in_storage || $self->_result->is_column_changed($note_field) ) {
237
                    $self->$note_field(C4::Scrubber->new('comment')->scrub($self->$note_field));
238
                }
239
            }
240
234
            unless ( $self->in_storage ) {    #AddMember
241
            unless ( $self->in_storage ) {    #AddMember
235
242
236
                # Generate a valid userid/login if needed
243
                # Generate a valid userid/login if needed
(-)a/t/db_dependent/Koha/Patron.t (-2 / +33 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 32;
22
use Test::More tests => 33;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
use Time::Fake;
25
use Time::Fake;
Lines 2234-2236 subtest 'guarantor requirements tests' => sub { Link Here
2234
    'Koha::Exceptions::Patron::Relationship::NoGuarantor',
2234
    'Koha::Exceptions::Patron::Relationship::NoGuarantor',
2235
        'Exception thrown when guarantor is deleted.';
2235
        'Exception thrown when guarantor is deleted.';
2236
};
2236
};
2237
- 
2237
2238
subtest 'Scrub the note fields' => sub {
2239
    plan tests => 4;
2240
2241
    $schema->storage->txn_begin;
2242
2243
    my $bad_message     = '<script>alert("booh!")</script><span>all</span><b>good</b>now';
2244
    my $cleaned_message = '<span>all</span><b>good</b>now';
2245
    my $tmp_patron      = $builder->build_object( { class => 'Koha::Patrons' } );
2246
    my $patron_data     = $tmp_patron->unblessed;
2247
    $tmp_patron->delete;
2248
    delete $tmp_patron->{borrowernumber};
2249
2250
    my $patron = Koha::Patron->new(
2251
2252
        {
2253
            %$patron_data,
2254
            borrowernotes => $bad_message, opacnote => $bad_message,
2255
        }
2256
    )->store;
2257
2258
    is( $patron->get_from_storage->borrowernotes, $cleaned_message );
2259
    is( $patron->get_from_storage->opacnote,      $cleaned_message );
2260
2261
    $patron->borrowernotes($bad_message)->store;
2262
    $patron->opacnote($bad_message)->store;
2263
2264
    is( $patron->get_from_storage->borrowernotes, $cleaned_message );
2265
    is( $patron->get_from_storage->opacnote,      $cleaned_message );
2266
2267
    $schema->storage->txn_rollback;
2268
};

Return to bug 19613