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

(-)a/C4/Biblio.pm (-2 / +2 lines)
Lines 2239-2245 sub TransformHtmlToMarc { Link Here
2239
                    ;
2239
                    ;
2240
                    # between 001 and 009 (included)
2240
                    # between 001 and 009 (included)
2241
                } elsif ( $fval ne '' ) {
2241
                } elsif ( $fval ne '' ) {
2242
                    $fval = StripNonXmlChars($fval); #Strip out any non-XML characters like control characters
2242
                    $fval = StripNonXmlChars($fval);    #Strip out any non-XML characters like control characters
2243
                    $newfield = MARC::Field->new( $tag, $fval, );
2243
                    $newfield = MARC::Field->new( $tag, $fval, );
2244
                }
2244
                }
2245
2245
Lines 2261-2267 sub TransformHtmlToMarc { Link Here
2261
                        $newfield->add_subfields( $fkey => $fval);
2261
                        $newfield->add_subfields( $fkey => $fval);
2262
                    }
2262
                    }
2263
                    elsif($fval ne '') {
2263
                    elsif($fval ne '') {
2264
                        $fval = StripNonXmlChars($fval); #Strip out any non-XML characters like control characters
2264
                        $fval = StripNonXmlChars($fval);    #Strip out any non-XML characters like control characters
2265
                        $newfield = MARC::Field->new( $tag, $ind1, $ind2, $fkey => $fval );
2265
                        $newfield = MARC::Field->new( $tag, $ind1, $ind2, $fkey => $fval );
2266
                    }
2266
                    }
2267
                    $j += 2;
2267
                    $j += 2;
(-)a/t/db_dependent/Biblio/TransformHtmlToMarc.t (-5 / +7 lines)
Lines 76-82 subtest 'Biblio record' => sub { Link Here
76
    # A field (900) after 490
76
    # A field (900) after 490
77
    $input->param( -name => "tag_900_indicator1_1123", -value => "" );
77
    $input->param( -name => "tag_900_indicator1_1123", -value => "" );
78
    $input->param( -name => "tag_900_indicator2_1123", -value => "" );
78
    $input->param( -name => "tag_900_indicator2_1123", -value => "" );
79
    $input->param( -name => "tag_900_code_a_1123", -value => 'a' );
79
    $input->param( -name => "tag_900_code_a_1123",     -value => 'a' );
80
    $input->param( -name => "tag_900_subfield_a_1123", -value => "This string has bad \x{1B}characters in it" );
80
    $input->param( -name => "tag_900_subfield_a_1123", -value => "This string has bad \x{1B}characters in it" );
81
81
82
    my $record = C4::Biblio::TransformHtmlToMarc($input, 1);
82
    my $record = C4::Biblio::TransformHtmlToMarc($input, 1);
Lines 100-106 subtest 'Biblio record' => sub { Link Here
100
100
101
    my @fields_900 = $record->field('900');
101
    my @fields_900 = $record->field('900');
102
    is( @fields_900, 1, 'The record should have been created with 1 900' );
102
    is( @fields_900, 1, 'The record should have been created with 1 900' );
103
    is_deeply( $fields_900[0]->subfields(), [ 'a', 'This string has bad characters in it' ], 'Field 900 had its non-XML characters stripped');
103
    is_deeply(
104
        $fields_900[0]->subfields(), [ 'a', 'This string has bad characters in it' ],
105
        'Field 900 had its non-XML characters stripped'
106
    );
104
107
105
    my @subfields_biblionumber = $record->subfield( $biblionumbertagfield, $biblionumbertagsubfield );
108
    my @subfields_biblionumber = $record->subfield( $biblionumbertagfield, $biblionumbertagsubfield );
106
    is( @subfields_biblionumber, 1, 'The record should contain only one biblionumber field' );
109
    is( @subfields_biblionumber, 1, 'The record should contain only one biblionumber field' );
Lines 116-124 subtest 'Biblio record' => sub { Link Here
116
    is( $all_fields[5]->subfield('a'), 42, 'Sixth field contains bibnumber' );
119
    is( $all_fields[5]->subfield('a'), 42, 'Sixth field contains bibnumber' );
117
    is( $all_fields[6]->tag, '490', 'Last field is 490' );
120
    is( $all_fields[6]->tag, '490', 'Last field is 490' );
118
121
119
    my $new_record = eval { MARC::Record::new_from_xml( $record->as_xml(), 'UTF-8' ); };
122
    my $new_record   = eval { MARC::Record::new_from_xml( $record->as_xml(), 'UTF-8' ); };
120
    my $record_error = $@;
123
    my $record_error = $@;
121
    ok( ! $record_error,'No errors parsing MARCXML generated by TransformHtmlToMarc');
124
    ok( !$record_error, 'No errors parsing MARCXML generated by TransformHtmlToMarc' );
122
125
123
};
126
};
124
127
125
- 

Return to bug 34549