Bugzilla – Attachment 194168 Details for
Bug 35104
We should warn when attempting to save MARC records that contain characters invalid in XML
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35104: Use Unicode Control Pictures in nonxml_stripped context snippets
cb05a09.patch (text/plain), 3.05 KB, created by
Martin Renvoize (ashimema)
on 2026-02-27 19:24:15 UTC
(
hide
)
Description:
Bug 35104: Use Unicode Control Pictures in nonxml_stripped context snippets
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-27 19:24:15 UTC
Size:
3.05 KB
patch
obsolete
>From cb05a0924a42079a6c2947c5f61f334c307cbb4d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Fri, 27 Feb 2026 14:32:28 +0000 >Subject: [PATCH] Bug 35104: Use Unicode Control Pictures in nonxml_stripped > context snippets > >Instead of a [U+XXXX] marker, the context snippet now shows a visible >glyph in place of the stripped character: > > C0 controls (U+0000-U+001F) -> Unicode Control Pictures (U+2400-U+241F) > DEL (U+007F) -> U+2421 SYMBOL FOR DELETE (?) > other non-XML characters -> U+FFFD REPLACEMENT CHARACTER (?) > >The first line of the error message is unchanged, continuing to identify >the character by its decimal value and U+XXXX code: > > 336$a: invalid char value 8 (U+0008) at position 12 > t $xtac arr?\ $btxt V $2rdac ontent > ^ >--- > Koha/Biblio/Metadata.pm | 27 ++++++++++++++++++--------- > 1 file changed, 18 insertions(+), 9 deletions(-) > >diff --git a/Koha/Biblio/Metadata.pm b/Koha/Biblio/Metadata.pm >index 7207eec2f08..6cb83e2a6af 100644 >--- a/Koha/Biblio/Metadata.pm >+++ b/Koha/Biblio/Metadata.pm >@@ -394,26 +394,35 @@ a bad character, and its ordinal C<$char_ord>, returns a two-line string: > =over 4 > > =item * Line 1 â up to 30 characters of context either side of the bad >-character, with the bad character replaced by a C<[U+XXXX]> marker and >-ellipses when the window is truncated. >+character, with the bad character replaced by a visible glyph (Unicode >+Control Pictures U+2400âU+241F for C0 controls, C<â¡> for DEL, C<?> >+otherwise) and ellipses when the window is truncated. > >-=item * Line 2 â a caret (C<^>) aligned beneath the start of the marker. >+=item * Line 2 â a caret (C<^>) aligned beneath the visible glyph. > > =back > > Example output (4-space indent): > >- ...arr \ [U+0008]$btxt V $2rdac ontent >- ^ >+ t $xtac arrâ\ $btxt V $2rdac ontent >+ ^ > > =cut > > sub _context_snippet { > my ( $chars_ref, $pos_0, $char_ord ) = @_; > >- my $marker = sprintf '[U+%04X]', $char_ord; >- my $last = $#{$chars_ref}; >- my $win = 30; >+ # Visible stand-in for the removed character: >+ # C0 controls (U+0000âU+001F) â Unicode Control Pictures (U+2400âU+241F) >+ # DEL (U+007F) â U+2421 SYMBOL FOR DELETE (â¡) >+ # anything else â U+FFFD REPLACEMENT CHARACTER (?) >+ my $visible = >+ $char_ord <= 0x1F ? chr( $char_ord + 0x2400 ) >+ : $char_ord == 0x7F ? "\x{2421}" >+ : "\x{FFFD}"; >+ >+ my $last = $#{$chars_ref}; >+ my $win = 30; > > my $pre_start = ( $pos_0 > $win ) ? $pos_0 - $win : 0; > my $post_end = ( $pos_0 + $win < $last ) ? $pos_0 + $win : $last; >@@ -425,7 +434,7 @@ sub _context_snippet { > my $suffix = ( $pos_0 + $win < $last ) ? '...' : ''; > > my $indent = ' '; >- my $line = "$indent$prefix$pre$marker$post$suffix"; >+ my $line = "$indent$prefix$pre$visible$post$suffix"; > my $caret_col = length($indent) + length($prefix) + length($pre); > > return "$line\n" . ( ' ' x $caret_col ) . '^'; >-- >2.53.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 35104
:
157625
|
157627
|
157628
|
157642
|
159615
|
159620
|
159621
|
159630
|
159810
|
159811
|
159812
|
159813
|
166431
|
173145
|
173146
|
176820
|
176821
|
176850
|
176851
|
176852
|
176860
|
193985
|
193986
|
193987
|
193988
|
193989
|
193990
|
193991
|
193992
|
193993
|
193994
|
193995
|
193996
|
193997
|
193998
|
193999
|
194000
|
194001
|
194004
|
194005
|
194006
|
194007
|
194008
|
194009
|
194010
|
194011
|
194012
|
194013
|
194152
|
194153
|
194154
|
194155
|
194156
|
194157
|
194158
|
194159
|
194160
|
194161
|
194162
|
194163
|
194164
|
194165
|
194166
|
194167
| 194168 |
194169
|
194170
|
194171
|
194172