From 93f18ff0062954a199bee88aea56975472cf456d Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Mon, 2 Jan 2017 10:51:48 -0500 Subject: [PATCH] LP 1542495: Remove OpenILS::SIP::clean_text. This commit removes the OpenILS::SIP::clean_text utility function and all references to it in the OpenILS::SIP modules. Its job is now done in SIPServer's write_msg routine. Signed-off-by: Jason Stephenson Signed-off-by: Martha Driscoll Signed-off-by: Galen Charlton --- Open-ILS/src/perlmods/lib/OpenILS/SIP.pm | 44 ---------------- Open-ILS/src/perlmods/lib/OpenILS/SIP/Item.pm | 12 ++--- .../src/perlmods/lib/OpenILS/SIP/Patron.pm | 52 +++++++++---------- 3 files changed, 31 insertions(+), 77 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm index 998ea8509d..e2639cc535 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm @@ -25,8 +25,6 @@ use OpenSRF::Utils::SettingsClient; use OpenILS::Application::AppUtils; use OpenSRF::Utils qw/:datetime/; use DateTime::Format::ISO8601; -use Encode; -use Unicode::Normalize; my $U = 'OpenILS::Application::AppUtils'; @@ -129,48 +127,6 @@ sub make_editor { return OpenILS::Utils::CStoreEditor->new; } -=head2 clean_text(scalar) - -Evergreen uses the UTF8 encoding for everything from the database up. Perl -doesn't know this, however, so we have to convince it to treat our UTF8 strings -as UTF8 strings. This may enable OpenNCIP to correctly calculate the checksums -for UTF8 text for SIP clients that support such modern options. - -The target encoding is set in the element of the SIPServer.pm -configuration file. - -=cut - -sub clean_text { - my $text = shift || ''; - - # Convert our incoming UTF8 data into Perl's internal string format - - # Also convert to Normalization Form D, as the ASCII, iso-8859-1, - # and latin-1 encodings (at least) require this to substitute - # characters rather than simply returning a string truncated - # after the first non-ASCII character - $text = NFD(decode_utf8($text)); - - if ($target_encoding eq 'ascii') { - - # Try to maintain a reasonable version of the content by - # stripping diacritics from the text, given that the SIP client - # wants just plain ASCII. This is the base requirement according - # to the SIP2 specification. - - # Stripping the combining characters converts ""béè♁ts" - # into "bee?ts" instead of "b???ts" - better, eh? - $text =~ s/\pM+//og; - } - - # Characters that cannot be represented in the target encoding will - # generally be replaced with a question mark (?) character. - $text = encode($target_encoding, $text); - - return $text; -} - my %org_sn_cache; sub shortname_from_id { my $id = shift or return; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Item.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Item.pm index b32fb01cd9..0c598257b8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Item.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Item.pm @@ -271,17 +271,17 @@ sub sip_media_type { sub title_id { my $self = shift; my $t = ($self->{mods}) ? $self->{mods}->title : $self->{copy}->dummy_title; - return OpenILS::SIP::clean_text($t); + return $t; } sub permanent_location { my $self = shift; - return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname); + return $self->{copy}->circ_lib->shortname; } sub current_location { my $self = shift; - return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname); + return $self->{copy}->circ_lib->shortname; } @@ -340,7 +340,7 @@ sub fee_currency { sub owner { my $self = shift; - return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname); + return $self->{copy}->circ_lib->shortname; } sub hold_queue { @@ -418,14 +418,14 @@ sub hold_pickup_date { # message to display on console sub screen_msg { my $self = shift; - return OpenILS::SIP::clean_text($self->{screen_msg}) || ''; + return $self->{screen_msg} || ''; } # reciept printer sub print_line { my $self = shift; - return OpenILS::SIP::clean_text($self->{print_line}) || ''; + return $self->{print_line} || ''; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm index 23e234c972..cf6375ac21 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm @@ -242,11 +242,10 @@ sub name { sub format_name { my $u = shift; - return OpenILS::SIP::clean_text( - sprintf('%s %s %s', - ($u->first_given_name || ''), - ($u->second_given_name || ''), - ($u->family_name || ''))); + return sprintf('%s %s %s', + ($u->first_given_name || ''), + ($u->second_given_name || ''), + ($u->family_name || '')); } sub home_library { @@ -259,19 +258,18 @@ sub home_library { sub __addr_string { my $addr = shift; return "" unless $addr; - my $return = OpenILS::SIP::clean_text( - join( ' ', map {$_ || ''} ( - $addr->street1, - $addr->street2, - $addr->city . ',', - $addr->county, - $addr->state, - $addr->country, - $addr->post_code - ) - ) - ); - $return =~ s/\s+/ /sg; # Compress any run of of whitespace to one space + my $return = join( ' ', map {$_ || ''} + ( + $addr->street1, + $addr->street2, + $addr->city . ',', + $addr->county, + $addr->state, + $addr->country, + $addr->post_code + ) + ); + $return =~ s/\s+/ /sg; # Compress any run of of whitespace to one space return $return; } @@ -290,7 +288,7 @@ sub address { sub email_addr { my $self = shift; - return OpenILS::SIP::clean_text($self->{user}->email); + return $self->{user}->email; } sub home_phone { @@ -322,7 +320,7 @@ sub ptype { [$self->{user}->profile->id, {no_i18n => 1}])->name if $use_code =~ /true/io; - return OpenILS::SIP::clean_text($self->{user}->profile->name); + return $self->{user}->profile->name; } sub language { @@ -578,7 +576,7 @@ sub __format_holds { } else { push(@response, - OpenILS::SIP::clean_text($self->__hold_to_title($hold))); + $self->__hold_to_title($hold)); } } @@ -777,7 +775,7 @@ sub overdue_items { if($return_datatype eq 'barcode') { push( @o, __circ_to_barcode($self->{editor}, $circid)); } else { - push( @o, OpenILS::SIP::clean_text(__circ_to_title($self->{editor}, $circid))); + push( @o, __circ_to_title($self->{editor}, $circid)); } } @overdues = @o; @@ -834,7 +832,7 @@ sub charged_items_impl { if($return_datatype eq 'barcode' or $force_bc) { push( @c, __circ_to_barcode($self->{editor}, $circid)); } else { - push( @c, OpenILS::SIP::clean_text(__circ_to_title($self->{editor}, $circid))); + push( @c, __circ_to_title($self->{editor}, $circid)); } } @@ -862,7 +860,7 @@ sub fine_items { } else { $line .= $xact->last_billing_note; } - push @fines, OpenILS::SIP::clean_text($line); + push @fines, $line; } }; my $log_status = $@ ? 'ERROR: ' . $@ : 'OK'; @@ -899,7 +897,7 @@ sub block { # retrieve the un-fleshed user object for update $u = $e->retrieve_actor_user($u->id); - my $note = OpenILS::SIP::clean_text($u->alert_message) || ""; + my $note = $u->alert_message || ""; $note = " CARD BLOCKED BY SELF-CHECK MACHINE. $blocked_card_msg\n$note"; # XXX Config option $note =~ s/\s*$//; # kill trailng whitespace $u->alert_message($note); @@ -941,7 +939,7 @@ sub enable { # retrieve the un-fleshed user object for update $u = $e->retrieve_actor_user($u->id); - my $note = OpenILS::SIP::clean_text($u->alert_message) || ""; + my $note = $u->alert_message || ""; $note =~ s#.*##; $note =~ s/^\s*//; # kill leading whitespace $note =~ s/\s*$//; # kill trailng whitespace @@ -977,7 +975,7 @@ sub inet_privileges { my $e = OpenILS::SIP->editor(); $INET_PRIVS = $e->retrieve_all_config_net_access_level() unless $INET_PRIVS; my ($level) = grep { $_->id eq $self->{user}->net_access_level } @$INET_PRIVS; - my $name = OpenILS::SIP::clean_text($level->name); + my $name = $level->name; syslog('LOG_DEBUG', "OILS: Patron inet_privs = $name"); return $name; } -- 2.43.2