Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #417 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

XML encoding does not work properly depending on KCODE

Reported by: nahi Assigned to: nahi
Priority: high Milestone: 1.5.8
Component: soap4r Version: 1.5
Keywords: Cc:

Description

須藤です。

SOAP4Rで$KCODEと処理対象の文字列(メソッドの戻り値など)のエ ンコーディングが異なると、「<」などのエスケープが漏れる場合 がありました。

soap/generator.rbのencode_stringが問題の場所なのですが、irb で再現させてもらいます。

  % irb -r nkf
  irb(main):001:0> str = NKF.nkf("-w", "く<")
  => "\343\201\217<"
  irb(main):002:0> $KCODE = "EUC-JP"
  => "EUC-JP"
  irb(main):003:0> require 'soap/generator'
  => true
  irb(main):004:0> generator = SOAP::SOAPGenerator.new
  => #<SOAP::SOAPGenerator:0x2b601929a3e8 @curr=nil, @default_encodingstyle="http://schemas.xmlsoap.org/soap/encoding/", @use_numeric_character_reference=nil, @charset="utf-8", @elementformdefault=nil, @buf=nil, @handlers={}, @generate_explicit_type=true, @attributeformdefault=nil, @reftarget=nil, @indentstr="  ", @indent=nil>
  irb(main):005:0> generator.instance_variable_set("@buf", "")
  => ""
  irb(main):006:0> generator.encode_string(str)
  => "く<"
  irb(main):007:0> 

使用バージョンは以下のとおりです。

  % ruby -v -r soap/soap -e 'puts SOAP::VERSION'
  ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
  1.5.8-RC

この問題はsoap/generator.rbを以下のように変更すれば回避できる のですが、これで問題がないかどうかはわかりません。。。

-  EncodeCharRegexp = Regexp.new("[#{EncodeMap.keys.join}]")
+  EncodeCharRegexp = Regexp.new("[#{EncodeMap.keys.join}]", 0, "NONE")

Change History

09/09/07 17:19:29 changed by nahi

  • status changed from new to closed.
  • resolution set to fixed.

(In [1947]) * XML encoding does not work properly depending on CES. Generator should use an escaping Regexp according to XSD::Charset.encoding. including cosmetic changes ("NONE" -> 'NONE') closes #417.