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

(-)a/C4/Koha.pm (+20 lines)
Lines 61-66 BEGIN { Link Here
61
		&GetNormalizedISBN
61
		&GetNormalizedISBN
62
		&GetNormalizedEAN
62
		&GetNormalizedEAN
63
		&GetNormalizedOCLCNumber
63
		&GetNormalizedOCLCNumber
64
        &xml_escape
64
65
65
		$DEBUG
66
		$DEBUG
66
	);
67
	);
Lines 1190-1195 sub GetKohaAuthorisedValuesFromField { Link Here
1190
  }
1191
  }
1191
}
1192
}
1192
1193
1194
=head2 xml_escape
1195
1196
  my $escaped_string = C4::Koha::xml_escape($string);
1197
1198
Convert &, <, >, ', and " in a string to XML entities
1199
1200
=cut
1201
1202
sub xml_escape {
1203
    my $str = shift;
1204
    return '' unless defined $str;
1205
    $str =~ s/&/&amp;/g;
1206
    $str =~ s/</&lt;/g;
1207
    $str =~ s/>/&gt;/g;
1208
    $str =~ s/'/&apos;/g;
1209
    $str =~ s/"/&quot;/g;
1210
    return $str;
1211
}
1212
1193
=head2 display_marc_indicators
1213
=head2 display_marc_indicators
1194
1214
1195
  my $display_form = C4::Koha::display_marc_indicators($field);
1215
  my $display_form = C4::Koha::display_marc_indicators($field);
(-)a/C4/XSLT.pm (-3 / +2 lines)
Lines 210-218 sub buildKohaItemsNamespace { Link Here
210
        } else {
210
        } else {
211
            $status = "available";
211
            $status = "available";
212
        }
212
        }
213
        my $homebranch = $branches->{$item->{homebranch}}->{'branchname'};
213
        my $homebranch = xml_escape($branches->{$item->{homebranch}}->{'branchname'});
214
	 my $itemcallnumber = $item->{itemcallnumber} || '';
214
	    my $itemcallnumber = xml_escape($item->{itemcallnumber});
215
        $itemcallnumber =~ s/\&/\&amp\;/g;
216
        $xml.= "<item><homebranch>$homebranch</homebranch>".
215
        $xml.= "<item><homebranch>$homebranch</homebranch>".
217
		"<status>$status</status>".
216
		"<status>$status</status>".
218
		"<itemcallnumber>".$itemcallnumber."</itemcallnumber>"
217
		"<itemcallnumber>".$itemcallnumber."</itemcallnumber>"
(-)a/t/Koha.t (-2 / +7 lines)
Lines 2-8 Link Here
2
use strict;
2
use strict;
3
use warnings;
3
use warnings;
4
4
5
use Test::More tests => 2;
5
use Test::More tests => 5;
6
6
7
use_ok('C4::Koha');
7
use_ok('C4::Koha');
8
8
Lines 13-15 my $date = "01/01/2002"; Link Here
13
my $newdate = &slashifyDate("2002-01-01");
13
my $newdate = &slashifyDate("2002-01-01");
14
14
15
ok($date eq $newdate, 'slashifyDate');
15
ok($date eq $newdate, 'slashifyDate');
16
- 
16
17
my $undef = undef;
18
is(xml_escape($undef), '', 'xml_escape() returns empty string on undef input');
19
my $str = q{'"&<>'};
20
is(xml_escape($str), '&apos;&quot;&amp;&lt;&gt;&apos;', 'xml_escape() works as expected');
21
is($str, q{'"&<>'}, '... and does not change input in place');

Return to bug 5301