From af1f3118371108845e9944bf284ae022c922b977 Mon Sep 17 00:00:00 2001 From: mxbeaulieu Date: Wed, 4 Mar 2015 16:51:22 -0500 Subject: [PATCH] Fixed logical test in tmpl_process3.pl The line: next if $a eq 'value' && ($tag ne 'input' || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/)); # FIXME This portion: (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/) checks if the input type is valid. We get the following (wrong) logic: next IF $a eq value AND the tag is not an input OR the input type is valid The test is true when : $a eq value, tag is an input, input type is valid We skip the tag when it is valid, it is never translated. I propose the following change: my $isValidType = ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/; next if $a eq 'value' && !($tag eq 'input' && $isValidType); next IF $a eq value AND NOT ( tag is an input AND input type is valid ) in short: NOT (tag is a valid input tag) [ Alternative ] ( Not included in patch ) next if $a eq 'value' && ($tag ne 'input' || (ref $attr->{'type'} && $attr->{'type'}->[1] !~ /^(?:checkbox|hidden|radio|text)$/)); No extra variable, at the cost of code readability. http://bugs.koha-community.org/show_bug.cgi?id=13794 --- misc/translator/tmpl_process3.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index cb671ae..c9dfa4e 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -64,8 +64,8 @@ sub text_replace_tag ($$) { if ($attr->{$a}) { next if $a eq 'label' && $tag ne 'optgroup'; next if $a eq 'content' && $tag ne 'meta'; - next if $a eq 'value' && ($tag ne 'input' || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/)); # FIXME - + my $isValidType = ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:checkbox|hidden|radio|text)$/; + next if $a eq 'value' && !($tag eq 'input' && $isValidType); my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME if ($val =~ /\S/s) { my $s = find_translation($val); -- 1.7.9.5