[PATCH 1/2] encode to UTF8 consistently

Dan Scott dscott at laurentian.ca
Fri Jun 17 13:50:26 EDT 2011


In read_SIP_packet(), we decode the incoming packet as UTF8 and then
encode it again before writing to the log, but not before returning the
message. We were instead encoding the incoming message in a subsequent
call, which is not the recommended Perl practice of decoding input and
encoding output.

Signed-off-by: Dan Scott <dscott at laurentian.ca>
---
 Sip.pm |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/Sip.pm b/Sip.pm
index 1e57916..42c6e02 100644
--- a/Sip.pm
+++ b/Sip.pm
@@ -209,7 +209,7 @@ sub read_SIP_packet {
     #  
     # This is now handled by the vigorous cleansing above.
     syslog("LOG_INFO", encode_utf8("INPUT MSG: '$record'")) if $record;
-    return $record;
+    return encode_utf8($record);
 }
 
 #
@@ -227,7 +227,6 @@ sub write_msg {
     my ($self, $msg, $file) = @_;
     my $cksum;
 
-    $msg = encode_utf8($msg);
     if ($error_detection) {
         if (defined($self->{seqno})) {
             $msg .= 'AY' . $self->{seqno};
-- 
1.7.5.4


--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="0002-Restore-Unicode-checksum-algorithm.patch"



More information about the Open-ils-dev mailing list