[Opensrf-commits] r2168 - trunk/src/perl/lib/OpenSRF (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Feb 22 09:28:21 EST 2011


Author: dbs
Date: 2011-02-22 09:28:19 -0500 (Tue, 22 Feb 2011)
New Revision: 2168

Modified:
   trunk/src/perl/lib/OpenSRF/Server.pm
Log:
Resolve encoding problem found by attempting to register patrons with Unicode names

Symptoms were:

1. a gateway.log entry showing http_translator receiving an XMPP error message
2. a corresponding osrfsys.log entry "server: died with error Wide character in syswrite at /usr/local/share/perl5/OpenSRF/Server.pm line 239"

Per normal Perl Unicode handling practices, decoding input and encoding output
using the Encode module and decode_utf8() / encode_utf8() appears to resolve
the problem.


Modified: trunk/src/perl/lib/OpenSRF/Server.pm
===================================================================
--- trunk/src/perl/lib/OpenSRF/Server.pm	2011-02-14 13:54:50 UTC (rev 2167)
+++ trunk/src/perl/lib/OpenSRF/Server.pm	2011-02-22 14:28:19 UTC (rev 2168)
@@ -22,6 +22,7 @@
 use OpenSRF::Utils::SettingsClient;
 use OpenSRF::Utils::Logger qw($logger);
 use OpenSRF::Transport::SlimJabber::Client;
+use Encode;
 use POSIX qw/:sys_wait_h :errno_h/;
 use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
 use IO::Select;
@@ -235,8 +236,8 @@
 # ----------------------------------------------------------------
 sub write_child {
     my($self, $child, $msg) = @_;
-    my $xml = $msg->to_xml;
-    syswrite($child->{pipe_to_child}, $xml);
+    my $xml = decode_utf8($msg->to_xml);
+    syswrite($child->{pipe_to_child}, encode_utf8($xml));
 }
 
 # ----------------------------------------------------------------



More information about the opensrf-commits mailing list