#163 The SOAP::Data have bug

0.71
closed-duplicate
Byrne Reese
Encoding (11)
5
2009-09-29
2009-07-11
lukeshei
No

note: win2003 + apache 2.2 + perl 5.10 + SOAP::Lite 0.710.05 (Both sever and client use SOAP::Lite)

$ret .= '0' . "\t帳號錯誤\t" . $u . "\n"; #utf8 and $u='test@test.com.tw'
return SOAP::Data->value($ret)->type("base64");

The result is error . The chinese word is error.

But.
$ret .= '0' . "\t帳號錯誤\t".'test@test.com.tw'."\n"; #utf8
return SOAP::Data->value($ret)->type("base64");

The result is correct.

And

$ret .= '0' . "\t帳號錯誤\t\n"; #utf8
return SOAP::Data->value($ret)->type("base64");

The result is correct.

Discussion

  • lukeshei
    lukeshei
    2009-07-11

    The SOAP::Lite 0.710.08 have the same problem.

     
  • lukeshei
    lukeshei
    2009-07-12

    I found that those error is cause by Encode::_utf8_off($ret);
    But i erase those lines in Lite.pm, the problem still exist.

     
  • lukeshei
    lukeshei
    2009-07-13

    The problem slove when i mark the line # Encode::_utf8_off($value); in Lite.pm.

    sub as_base64Binary {
    my ($self, $value, $name, $type, $attr) = @_;

    # Fixes #30271 for 5.8 and above.
    # Won't fix for 5.6 and below - perl can't handle unicode before
    # 5.8, and applying pack() to everything is just a slowdown.
    if (eval "require Encode; 1") {
    if (Encode::is_utf8($value)) {
    if (Encode->can('_utf8_off')) { # the quick way, but it may change in future Perl versions.
    # Encode::_utf8_off($value);
    }
    else {
    $value = pack('C*',unpack('C*',$value)); # the slow but safe way,
    # but this fallback works always.
    }
    }
    }

     
  • Martin Kutter
    Martin Kutter
    2009-09-29

    This is not a bug. Base64 transport octets, not utf8-encoded strings.

    The only solution is to re-transform the octets to a utf8-string on the client or server side.

    All approches to fix this in SOAP::Lite are fundamentally flawed - see also https://sourceforge.net/tracker/?func=detail&aid=2860559&group_id=66000&atid=513017 which is about the same (application) error.

    Martin

     
  • Martin Kutter
    Martin Kutter
    2009-09-29

    • status: open --> closed-duplicate