Bugzilla – Attachment 92872 Details for
Bug 21959
Add ability to apply regular expressions to text fields in the batch item modification tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21959: allow only i and g regex modifiers
Bug-21959-allow-only-i-and-g-regex-modifiers.patch (text/plain), 1.96 KB, created by
Biblibre Sandboxes
on 2019-09-17 10:32:57 UTC
(
hide
)
Description:
Bug 21959: allow only i and g regex modifiers
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2019-09-17 10:32:57 UTC
Size:
1.96 KB
patch
obsolete
>From 0ef3141f12cb7d884d8696476d38933ea4ebf0ed Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Tue, 2 Apr 2019 16:14:39 +0200 >Subject: [PATCH] Bug 21959: allow only i and g regex modifiers > >Signed-off-by: Mathilde Formery <mathilde.formery@ville-nimes.fr> >--- > tools/batchMod.pl | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 3874b41..4f3721b 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -224,12 +224,28 @@ if ($op eq "action") { > my $tag = $tags[$i]; > my $subfield = $subfields[$i]; > my $replace = $replaces[$i]; >- my $mod = $modifiers[$i]; > > my $value = $localmarcitem->field( $tag )->subfield( $subfield ); > my $old_value = $value; >- ## no critic (StringyEval) >- eval "\$value =~ s/$search/$replace/$mod"; >+ >+ my @available_modifiers = qw( i g ); >+ my $retained_modifiers = q||; >+ for my $modifier ( split //, $modifiers[$i] ) { >+ $retained_modifiers .= $modifier >+ if grep {/$modifier/} @available_modifiers; >+ } >+ if ( $retained_modifiers =~ m/^(ig|gi)$/ ) { >+ $value =~ s/$search/$replace/ig; >+ } >+ elsif ( $retained_modifiers eq 'i' ) { >+ $value =~ s/$search/$replace/i; >+ } >+ elsif ( $retained_modifiers eq 'g' ) { >+ $value =~ s/$search/$replace/g; >+ } >+ else { >+ $value =~ s/$search/$replace/; >+ } > > my @fields_to = $localmarcitem->field($tag); > foreach my $field_to_update ( @fields_to ) { >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21959
:
82902
|
83392
|
83470
|
87323
|
87324
|
87325
|
92870
|
92871
|
92872
|
95432
|
95433
|
95434
|
96636
|
96637
|
96638