From f78f73e1f3771d9569a6c558081fa06fd4d78811 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 4 Apr 2022 02:34:55 +0000 Subject: [PATCH] Bug 30358: (follow-up) Also strip inner newlines This patch amends the StripWhitespaceChars system preference to also strip inner newlines (line breaks and carriage returns) when enabled. Signed-off-by: David Nind Signed-off-by: Kyle M Hall --- C4/AuthoritiesMarc.pm | 2 +- C4/Biblio.pm | 2 +- .../bug_30358_-_add_StripWhitespaceChars_syspref.pl | 2 +- installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../prog/en/modules/admin/preferences/cataloguing.pref | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 56add2d5a8..36901861fa 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -663,7 +663,7 @@ sub AddAuthority { foreach my $subfield ( $field->subfields ) { my $key = $subfield->[0]; my $value = $subfield->[1]; - $value =~ s/^\s+|\s+$|^\n+|\n+$|^\r+|\r+$|^\t+|\t+$//g; + $value =~ s/^\s+|\s+$|\n+|\r+|^\t+|\t+$//g; $field->update( $key => $value ); } } diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 5a66e0e5e1..6e3053f0d3 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2816,7 +2816,7 @@ sub ModBiblioMarc { foreach my $subfield ( $field->subfields ) { my $key = $subfield->[0]; my $value = $subfield->[1]; - $value =~ s/^\s+|\s+$|^\n+|\n+$|^\r+|\r+$|^\t+|\t+$//g; + $value =~ s/^\s+|\s+$|\n+|\r+|^\t+|\t+$//g; $field->update( $key => $value ); } } diff --git a/installer/data/mysql/atomicupdate/bug_30358_-_add_StripWhitespaceChars_syspref.pl b/installer/data/mysql/atomicupdate/bug_30358_-_add_StripWhitespaceChars_syspref.pl index 80957d8145..1a6f0356e9 100644 --- a/installer/data/mysql/atomicupdate/bug_30358_-_add_StripWhitespaceChars_syspref.pl +++ b/installer/data/mysql/atomicupdate/bug_30358_-_add_StripWhitespaceChars_syspref.pl @@ -7,6 +7,6 @@ return { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('StripWhitespaceChars', '0', NULL, 'Strip leading and trailing whitespace characters from input fields when cataloguing bibliographic and authority records.', 'YesNo') }); + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('StripWhitespaceChars', '0', NULL, 'Strip leading and trailing whitespace characters and inner newlines from input fields when cataloguing bibliographic and authority records.', 'YesNo') }); }, }; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index eb8058357a..cd51fd6b24 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -698,7 +698,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('StatisticsFields','location|itype|ccode', NULL, 'Define Fields (from the items table) used for statistics members','Free'), ('StockRotation','0',NULL,'If ON, enables the stock rotation module','YesNo'), ('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo'), -('StripWhitespaceChars','0',NULL,'Strip leading and trailing whitespace characters from input fields when cataloguing bibliographic and authority records.','YesNo'), +('StripWhitespaceChars','0',NULL,'Strip leading and trailing whitespace characters and inner newlines from input fields when cataloguing bibliographic and authority records.','YesNo'), ('SubfieldsToAllowForRestrictedBatchmod','','Define a list of subfields for which edition is authorized when items_batchmod_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j',NULL,'Free'), ('SubfieldsToAllowForRestrictedEditing','','Define a list of subfields for which edition is authorized when edit_items_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j',NULL,'Free'), ('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 44db9f944a..76be1b66c5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -210,7 +210,7 @@ Cataloging: choices: 1: Strip 0: "Don't strip" - - leading and trailing whitespace characters from input fields when cataloguing bibliographic and authority records. Whitespace characters include spaces, tabs, newlines and carriage returns. + - leading and trailing whitespace characters (including spaces, tabs, line breaks and carriage returns) and inner newlines from input fields when cataloguing bibliographic and authority records. Display: - - 'Separate main entry and subdivisions with ' -- 2.30.2