Skip Menu |

This queue is for tickets about the XML-Compile CPAN distribution.

Report information
The Basics
Id: 108410
Status: resolved
Priority: 0/
Queue: XML-Compile

People
Owner: Nobody in particular
Requestors: mjgardner [...] cpan.org
Cc: peter.sandin [...] ziprecruiter.com
AdminCc:

Bug Information
Severity: Important
Broken in: 1.50
Fixed in: 1.51



CC: peter.sandin [...] ziprecruiter.com
Subject: base64Binary content becomes undef if it contains wide characters
I'm calling the service at https://webservices.netsuite.com/wsdl/v2015_1_0/netsuite.wsdl with XML::Compile::WSDL11. When attempting to send string content in a base64Binary element, I get errors like the following when the string contains wide characters: error: illegal value `undef' for type {http://www.w3.org/2001/XMLSchema}base64Binary at platformMsgs:upsert/record/mediaItemList/mediaItem/content Normally the MIME::Base64 encode_base64 function used by XML::Compile::Schema::BuiltInTypes's base64Binary support would croak on receiving wide characters on content without an encoding. However the calls to encode_base64 and decode_base64 in XML::Compile::Schema::BuiltInTypes (starting in line 306 in v1.50) are wrapped in eval calls, so the croak is neutered and the passed string becomes undef. The croaked error should instead be caught and passed as the correct error string, rather than the confusing message above. This would hint to the developer that they need to make sure their string has been encoded so that MIME::Base64 can correctly encode it to base64.
Subject: Re: [rt.cpan.org #108410] base64Binary content becomes undef if it contains wide characters
Date: Wed, 4 Nov 2015 09:21:18 +0100
To: Mark Gardner via RT <bug-XML-Compile [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Mark Gardner via RT (bug-XML-Compile@rt.cpan.org) [151103 17:46]: Show quoted text
> Tue Nov 03 12:46:36 2015: Request 108410 was acted upon. > Transaction: Ticket created by MJGARDNER > Queue: XML-Compile > Subject: base64Binary content becomes undef if it contains wide characters > > The croaked error should instead be caught and passed as the correct > error string, rather than the confusing message above. This would hint to > the developer that they need to make sure their string has been encoded > so that MIME::Base64 can correctly encode it to base64.
I agree. As second problem: you want to see the error, to get a hint about wide-characters. XML::Compile tries to hide as much as possible of the XML to the user of the module. Do we really want the user to understand that it is a base64 field, not just a string? So: wouldn't it be better to always call "utf8::downgrade" on the parameter? I think that base64 encoded fields are to be considered raw byte fields, not text string fields. So wide characters are accidents of Perl upgrading them, for instance in a regular expression. What do you think about this? -- greetz, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Agreed, just make sure to give the error if utf8::downgrade() fails and dies per the docs.
Subject: Re: [rt.cpan.org #108410] base64Binary content becomes undef if it contains wide characters
Date: Thu, 5 Nov 2015 09:19:45 +0100
To: Mark Gardner via RT <bug-XML-Compile [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Mark Gardner via RT (bug-XML-Compile@rt.cpan.org) [151104 13:45]: Show quoted text
> Queue: XML-Compile > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=108410 > > > Agreed, just make sure to give the error if utf8::downgrade() fails > and dies per the docs.
I have changed the format code into: $builtin_types{base64Binary} = { parse => sub { eval { decode_base64 $_[0] } } , format => sub { my $a = $_[0]; eval { utf8::downgrade($a) }; if($@) { error __x"use Encode::encode() for base64Binary field at {path}" , path => $_[2]; } encode_base64 $a, ''; } ... The regression-test script output on a wide character now says: use Encode::encode() for base64Binary field at {http://test-types}test6 So: it does not tell the error, but focusses on the solution. What do you think? -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
CC: Mark Joseph Gardner <mjgardner [...] cpan.org>, Peter Sandin <peter.sandin [...] ziprecruiter.com>
Subject: Re: [rt.cpan.org #108410] base64Binary content becomes undef if it contains wide characters
Date: Thu, 5 Nov 2015 11:47:03 -0500
To: Mark Overmeer via RT <bug-XML-Compile [...] rt.cpan.org>
From: Mark Gardner <mjg [...] phoenixtrap.com>
That looks OK. Can you provide a patch or dev release for me to test? Show quoted text
> On Nov 5, 2015, at 3:20 AM, Mark Overmeer via RT <bug-XML-Compile@rt.cpan.org> wrote: > > <URL: https://rt.cpan.org/Ticket/Display.html?id=108410 > > > * Mark Gardner via RT (bug-XML-Compile@rt.cpan.org) [151104 13:45]:
>> Queue: XML-Compile >> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=108410 > >> >> Agreed, just make sure to give the error if utf8::downgrade() fails >> and dies per the docs.
> > I have changed the format code into: > > $builtin_types{base64Binary} = > { parse => sub { eval { decode_base64 $_[0] } } > , format => sub { > my $a = $_[0]; > eval { utf8::downgrade($a) }; > if($@) > { error __x"use Encode::encode() for base64Binary field at {path}" > , path => $_[2]; > } > encode_base64 $a, ''; > } > ... > > The regression-test script output on a wide character now says: > > use Encode::encode() for base64Binary field at {http://test-types}test6 > > So: it does not tell the error, but focusses on the solution. > What do you think? > -- > Regards, > MarkOv > > ------------------------------------------------------------------------ > Mark Overmeer MSc MARKOV Solutions > Mark@Overmeer.net solutions@overmeer.net > http://Mark.Overmeer.net http://solutions.overmeer.net > >
Download signature.asc
application/pgp-signature 527b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #108410] base64Binary content becomes undef if it contains wide characters
Date: Thu, 5 Nov 2015 17:52:11 +0100
To: "mjg [...] phoenixtrap.com via RT" <bug-XML-Compile [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* mjg@phoenixtrap.com via RT (bug-XML-Compile@rt.cpan.org) [151105 16:47]: Show quoted text
> Queue: XML-Compile > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=108410 > > > That looks OK. Can you provide a patch or dev release for me to test?
I have now released it as XML::Compile v1.51 to CPAN. -- success, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Fixed some time ago