Bugzilla – Attachment 33248 Details for
Bug 8218
Add a script to sanitize entity where "&" character was wrongly replaced with "&"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8218: qa followup
Bug-8218-qa-followup.patch (text/plain), 4.42 KB, created by
Jonathan Druart
on 2014-11-05 15:10:32 UTC
(
hide
)
Description:
Bug 8218: qa followup
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-11-05 15:10:32 UTC
Size:
4.42 KB
patch
obsolete
>From cf56f210800130a8964fc1b304830df8051bc920 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 5 Nov 2014 16:09:04 +0100 >Subject: [PATCH] Bug 8218: qa followup > >This patch >- rename _entity_clean as _clean_ampersand >- rename the script to sanitize_records.pl >- add a --fix-ampersand switch (the only one FOR NOW, enabled by > default) so it is obvious what the script does. >- make POD and usage reflect this changes. >--- > C4/Charset.pm | 8 ++++---- > .../{batch_sanitize_records.pl => sanitize_records.pl} | 18 ++++++++++++++---- > 2 files changed, 18 insertions(+), 8 deletions(-) > rename misc/maintenance/{batch_sanitize_records.pl => sanitize_records.pl} (90%) > >diff --git a/C4/Charset.pm b/C4/Charset.pm >index e56422f..e43404b 100644 >--- a/C4/Charset.pm >+++ b/C4/Charset.pm >@@ -429,7 +429,7 @@ sub nsb_clean { > SanitizeRecord($marcrecord); > > Sanitize a record >-This routine is called in the maintenance script misc/maintenance/batch_sanitize_records.pl. >+This routine is called in the maintenance script misc/maintenance/sanitize_records.pl. > It cleans any string with '&amp;...', replacing it by '&' > > =cut >@@ -444,7 +444,7 @@ sub SanitizeRecord { > foreach my $field ( $record->fields() ) { > if ( $field->is_control_field() ) { > my $value = $field->data(); >- my $sanitized_value = _entity_clean($value); >+ my $sanitized_value = _clean_ampersand($value); > $record_modified = 1 if $sanitized_value ne $value; > $field->update($sanitized_value); > } >@@ -456,7 +456,7 @@ sub SanitizeRecord { > if $url_field eq $field->tag() > and $url_subfield eq $subfield->[0]; > my $value = $subfield->[1]; >- my $sanitized_value = _entity_clean($value); >+ my $sanitized_value = _clean_ampersand($value); > push @new_subfields, $subfield->[0] => $sanitized_value; > $record_modified = 1 if $sanitized_value ne $value; > } >@@ -481,7 +481,7 @@ sub SanitizeRecord { > return $record, $record_modified; > } > >-sub _entity_clean { >+sub _clean_ampersand { > my ($string) = @_; > $string =~ s/(&)(amp;)+/$1/g; > return $string; >diff --git a/misc/maintenance/batch_sanitize_records.pl b/misc/maintenance/sanitize_records.pl >similarity index 90% >rename from misc/maintenance/batch_sanitize_records.pl >rename to misc/maintenance/sanitize_records.pl >index b164ec2..b9caa4b 100755 >--- a/misc/maintenance/batch_sanitize_records.pl >+++ b/misc/maintenance/sanitize_records.pl >@@ -26,7 +26,7 @@ use Getopt::Long; > use Pod::Usage; > > my ( $help, $verbose, $confirm, $biblionumbers, $reindex, $filename, >- $auto_search ); >+ $auto_search, $fix_ampersand ); > my $result = GetOptions( > 'h|help' => \$help, > 'v|verbose' => \$verbose, >@@ -35,8 +35,13 @@ my $result = GetOptions( > 'reindex' => \$reindex, > 'f|filename:s' => \$filename, > 'auto-search' => \$auto_search, >+ 'fix-ampersand' => \$fix_ampersand, > ) || pod2usage(1); > >+# This script only fix ampersand at the moment. >+# It is enabled by default. >+$fix_ampersand = 1; >+ > if ($help) { > pod2usage(0); > } >@@ -154,13 +159,13 @@ sub biblios_to_sanitize { > > =head1 NAME > >-batch_sanitize_biblios - This script sanitizes a biblio, replacing '&amp;amp;etc.' with '&' in it. >+sanitize_records - This script sanitizes a record. > > =head1 SYNOPSIS > >-batch_sanitize_biblios.pl [-h|--help] [-v|--verbose] [-c|--confirm] [--biblionumbers=BIBLIONUMBER_LIST] [-f|--filename=FILENAME] [--auto-search] [--reindex] >+sanitize_records.pl [-h|--help] [-v|--verbose] [-c|--confirm] [--biblionumbers=BIBLIONUMBER_LIST] [-f|--filename=FILENAME] [--auto-search] [--reindex] [--fix-ampersand] > >-Replace '&' by '&' in a record. You can either give some biblionumbers or a file with biblionumbers or ask for an auto-search. >+You can either give some biblionumbers or a file with biblionumbers or ask for an auto-search. > > =head1 OPTIONS > >@@ -193,6 +198,11 @@ Give a biblionumber list using a filename. One biblionumber by line or separate > > Automatically search records containing "&" in biblioitems.marcxml or in the specified fields. > >+=item B<--fix-ampersand> >+ >+Replace '&' by '&' in the records. >+Replace '&amp;amp;etc.' with '&' in the records. >+ > =item B<--reindex> > > Reindex the modified records. >-- >2.1.0
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 8218
:
10039
|
10588
|
10589
|
11744
|
12591
|
13678
|
15826
|
16122
|
16720
|
26754
|
26755
|
29792
|
29793
|
29794
|
29795
|
29796
|
29798
|
30120
|
30121
| 33248