Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3359 Binary field incompatibilities
  3. THRIFT-3364

Fix ruby binary field encoding in TJSONProtocol

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.3
    • 0.10.0
    • Ruby - Library
    • None
    • Patch Available

    Description

      Ruby JSON protocol uses pack('m') method to encode Base64 string.
      It seems that it inserts a "\n" character every 60 characters.

      You can refer to these pages for this behavior.
      http://stackoverflow.com/questions/2620975/strange-n-in-base64-encoded-string-in-ruby
      http://ruby-doc.org/stdlib-2.2.3/libdoc/base64/rdoc/Base64.html

      Line feeds are added to every 60 encoded characters.

      This has been making it impossible to send long binary field data to other languages.
      I fixed this by using alternative encode method that is added in Ruby 1.9 (which should be OK).

      After the fix, I had to add Ruby namespace to DebugProtoTest.thrift to avoid name collision of "Base64" symbols that is used for new encode method and also as DebugProtoTest message name.

      I also removed extraneous double quote in encoded binary fields that resulted in invalid JSON.

      Attachments

        Activity

          People

            jensg Jens Geyer
            nsuke Nobuaki Sukegawa
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: