From fffa61fa7b8be3b3ce72c1f983b2fffb0e99adfa Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 26 Sep 2013 14:15:15 +0200 Subject: [PATCH] Bug 8015: Get rid of eval for evaluating =~ m// Koha::SimpleMarc::field_equals uses eval in order to check if a string matches a pattern. Now this eval is removed and the "regex" variable does not contain the regex separated character (/ or |). Regression: Before this patch, the user was able to user a modifier. Now it is not possible. Signed-off-by: Bernardo Gonzalez Kriegel --- Koha/SimpleMARC.pm | 2 +- .../modules/tools/marc_modification_templates.tt | 12 ++++++++---- t/db_dependent/MarcModificationTemplates.t | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm index e78fc92..94f6ab1 100644 --- a/Koha/SimpleMARC.pm +++ b/Koha/SimpleMARC.pm @@ -239,7 +239,7 @@ sub field_equals { if ( $regex ) { C4::Koha::Log( "Testing '$field_value' =~ m$value" ) if $debug >= 3; - return eval "\$field_value =~ m$value"; + return $field_value =~ m/$value/; } else { return $field_value eq $value; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt index 85c983b..f3538ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt @@ -9,6 +9,8 @@ $(document).ready(function() { $('#select_template').change(function() { $('#select_template').submit(); }); + $("span.match_regex_prefix" ).hide(); + $("span.match_regex_suffix" ).hide(); }); //]]> @@ -97,9 +99,11 @@ function onToFieldRegexChange( checkboxObj ) { function onConditionalRegexChange( checkboxObj ) { if ( checkboxObj.checked ) { - document.getElementById( 'match_regex_prefix' ).style.visibility='visible'; + $("span.match_regex_prefix" ).show(); + $("span.match_regex_suffix" ).show(); } else { - document.getElementById( 'match_regex_prefix' ).style.visibility='hidden'; + $("span.match_regex_prefix" ).hide(); + $("span.match_regex_suffix" ).hide(); } } @@ -346,7 +350,7 @@ function setSelectByValue( selectId, value ) { [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %] [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %] - [% IF ( ActionsLoo.conditional_regex ) %] RegEx m[% END %][% ActionsLoo.conditional_value %] + [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %][% ActionsLoo.conditional_value %]/ [% END %] [% ActionsLoo.description %] @@ -438,7 +442,7 @@ function setSelectByValue( selectId, value ) {