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

(-)a/C4/Biblio.pm (-2 / +2 lines)
Lines 2897-2904 sub ModBiblioMarc { Link Here
2897
            foreach my $subfield ( $field->subfields ) {
2897
            foreach my $subfield ( $field->subfields ) {
2898
                my $key = $subfield->[0];
2898
                my $key = $subfield->[0];
2899
                my $value = $subfield->[1];
2899
                my $value = $subfield->[1];
2900
                $value =~ s/^\s+|\s+$|^\t+|\t+$|^\n+|\n+$|^\r+|\r+$//g;
2900
                $value =~ s/[\n\r]+/ /g;
2901
                $value =~ s/\n+|\r+/ /g;
2901
                $value =~ s/^\s+|\s+$|^\t+|\t+$//g;
2902
                $field->update( $key => $value );
2902
                $field->update( $key => $value );
2903
            }
2903
            }
2904
        }
2904
        }
(-)a/t/db_dependent/Biblio/ModBiblioMarc.t (-7 / +6 lines)
Lines 49-72 subtest "Check MARC field length calculation" => sub { Link Here
49
subtest "StripWhitespaceChars tests" => sub {
49
subtest "StripWhitespaceChars tests" => sub {
50
    plan tests => 3;
50
    plan tests => 3;
51
51
52
    t::lib::Mocks->mock_preference('marcflavour', 'MARC21');
52
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
53
    t::lib::Mocks->mock_preference('StripWhitespaceChars', 0);
53
    t::lib::Mocks::mock_preference('StripWhitespaceChars', 0);
54
54
55
    my $biblio = t::lib::TestBuilder->new->build_sample_biblio;
55
    my $biblio = t::lib::TestBuilder->new->build_sample_biblio;
56
    my $record = MARC::Record->new;
56
    my $record = MARC::Record->new;
57
    $record->append_fields(
57
    $record->append_fields(
58
        MARC::Field->new( '245', '', '', a => "  My title\n" ),
58
        MARC::Field->new( '245', '', '', a => "  My\ntitle\n" ),
59
    );
59
    );
60
60
61
    my $title = $record->title;
61
    my $title = $record->title;
62
    is( $title, "  My title\n", 'Title has whitespace characters' );
62
    is( $title, "  My\ntitle\n", 'Title has whitespace characters' );
63
63
64
    C4::Biblio::ModBiblioMarc( $record, $biblio->biblionumber );
64
    C4::Biblio::ModBiblioMarc( $record, $biblio->biblionumber );
65
    my $savedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber });
65
    my $savedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber });
66
    my $savedtitle = $savedrec->title;
66
    my $savedtitle = $savedrec->title;
67
    is( $savedtitle, "  My title\n", "Title still has whitespace characters because StripWhitespaceChars is disabled" );
67
    is( $savedtitle, "  My\ntitle\n", "Title still has whitespace characters because StripWhitespaceChars is disabled" );
68
68
69
    t::lib::Mocks->mock_preference('StripWhitespaceChars', 1);
69
    t::lib::Mocks::mock_preference('StripWhitespaceChars', 1);
70
70
71
    C4::Biblio::ModBiblioMarc( $record, $biblio->biblionumber );
71
    C4::Biblio::ModBiblioMarc( $record, $biblio->biblionumber );
72
    my $amendedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber });
72
    my $amendedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber });
73
- 

Return to bug 30358