Use utf8::encode() instead of utf8::downgrade() #5

merged 2 commits into from Feb 5, 2014


None yet

3 participants

alexrj commented Jan 30, 2012

After updating to the most recent version of RPC::XML my applications broke. It looks like RPC::XML::Client is sending bad UTF-8 data.
I was using the *RPC::XML::utf8_downgrade = \&utf8::encode; hack but the recent RPC::XML updates made it useless.

Digging in the code, I noticed that RPC::XML::Client uses utf8::downgrade() to encode request data. After changing it to utf8::encode() everything is working again.

To check whether this change is good or not, I put these lines after the original call to utf8::downgrade():

# Treat the content strictly in-memory
utf8::downgrade($content = $req->as_string);
open my $fh, ">", "foo.txt";
binmode $fh;
print $fh $content;
close $fh;

Inspecting the resulting file with a text editor showed that the file doesn't include UTF-8 octects but 8-bit data. After the change to utf8::encode() the file actually contained valid UTF-8 text.

I only replaced utf8::downgrade() in the place that affected my applications, but I see there are other occurrences in the module files. You might want to check whether it should be there or not.

racke commented on 0379d06 Oct 22, 2012

Amazing, that seems to fix my UTF-8 RPC::XML::Client issue as well. Alessandro, thanks for the patch! Ryan, any chance to apply this patch?


alexrj commented Oct 22, 2013

@rjray, any chance you can give some attention to this? The module has been broken for quite some time.

rjray commented Feb 2, 2014

@alexrj, I am sorry for the lengthy delay in this. I have been having health issues that have greatly reduced my time and energy for Perl work beyond my day-job. I will look at this very soon, and unless I find a problem in any of my tests, I will merge it for the 0.78 release that I hope to have out soon.

@rjray rjray merged commit c00cd56 into rjray:master Feb 5, 2014
rjray commented Feb 5, 2014

OK, this is now merged. I noticed that this only changes utf8::downgrade to utf8::encode in two places, when there are several more in RPC::XML and one in RPC::XML::Server as well. I will do a follow-up commit to the code that catches these other occurrences.

@alexrj alexrj deleted the alexrj:utf8-encode branch Feb 5, 2014
alexrj commented Feb 5, 2014

Sorry about your health issues, I hope everything is fine now. Thank you for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment