1. Non-ASCII characters in the 942$h (biblioitems.cn_class)
would cause an edit to fail and lead to a corrupt MARC record in
biblioitems.marc and biblioitems.marcxml. Fixed by
turning on Perl's UTF-8 flag for MARC tag parameters
processed by C4::Biblio::TransformHtmlToMarc
2. Do not add empty 006 and 007 fields if the corresponding
input fields are blank.
3. Make it possible to save '0' as a valid subfield
value.
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
sub TransformHtmlToMarc {
my $params = shift;
my $cgi = shift;
sub TransformHtmlToMarc {
my $params = shift;
my $cgi = shift;
+
+ # explicitly turn on the UTF-8 flag for all
+ # 'tag_' parameters to avoid incorrect character
+ # conversion later on
+ my $cgi_params = $cgi->Vars;
+ foreach my $param_name (keys %$cgi_params) {
+ if ($param_name =~ /^tag_/) {
+ my $param_value = $cgi_params->{$param_name};
+ if (utf8::decode($param_value)) {
+ $cgi_params->{$param_name} = $param_value;
+ }
+ # FIXME - need to do something if string is not valid UTF-8
+ }
+ }
+
# creating a new record
my $record = MARC::Record->new();
my $i=0;
# creating a new record
my $record = MARC::Record->new();
my $i=0;
if ($tag eq '000' ) {
$record->leader($cgi->param($params->[$j+1])) if length($cgi->param($params->[$j+1]))==24;
# between 001 and 009 (included)
if ($tag eq '000' ) {
$record->leader($cgi->param($params->[$j+1])) if length($cgi->param($params->[$j+1]))==24;
# between 001 and 009 (included)
+ } elsif ($cgi->param($params->[$j+1]) ne '') {
$newfield = MARC::Field->new(
$tag,
$cgi->param($params->[$j+1]),
$newfield = MARC::Field->new(
$tag,
$cgi->param($params->[$j+1]),
while($params->[$j] =~ /_code_/){ # browse all it's subfield
my $inner_param = $params->[$j];
if ($newfield){
while($params->[$j] =~ /_code_/){ # browse all it's subfield
my $inner_param = $params->[$j];
if ($newfield){
- if($cgi->param($params->[$j+1])){ # only if there is a value (code => value)
+ if($cgi->param($params->[$j+1]) ne ''){ # only if there is a value (code => value)
$newfield->add_subfields(
$cgi->param($inner_param) => $cgi->param($params->[$j+1])
);
}
} else {
$newfield->add_subfields(
$cgi->param($inner_param) => $cgi->param($params->[$j+1])
);
}
} else {
- if ( $cgi->param($params->[$j+1]) ) { # creating only if there is a value (code => value)
+ if ( $cgi->param($params->[$j+1]) ne '' ) { # creating only if there is a value (code => value)
$newfield = MARC::Field->new(
$tag,
''.$ind1,
$newfield = MARC::Field->new(
$tag,
''.$ind1,