protobuf 2.8.5 → 2.8.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a856318d0dafa9da5a88d40dcc319c500e766a13
4
- data.tar.gz: 868ee8f458233c1bf2e62a9db3371a4b0f698391
3
+ metadata.gz: bae0f4fcbb6ab57fe7866db45ea440c29899979d
4
+ data.tar.gz: 0fb43022f7937ae06df7185a611eead5a9f2b217
5
5
  SHA512:
6
- metadata.gz: 138f5e2b81b0c2375012bbc6ee4bae97a2af3e53cb83e5f348ee407544c29628a6b4bbc6cdef95f44467ed9180a23ad93a148f6f3b8e2f00bd2768455ea89335
7
- data.tar.gz: 3775fad99cbc871003c146c8c86cc2a2e1a9ab29f439bfd5b12e0e0c115fd18ba4f70558095f1b48a3a54910361c47e6de20fcb6c514e3ae0ab470a510217aaa
6
+ metadata.gz: b063acb75ac9ce464056edc2d418cc588e6b0ac0b885441a57f9dfc8c5795ee87faba8d393c09f6a91a8d12417808a2dd5603643988bd8c821b76dc1fd1608dd
7
+ data.tar.gz: 310368ac66f9e72150575ef01ec7f6cd7a1fba31a5bf33b926ca0743b1e907b623fd566d4b95f8a19ee4c5fc3b02b5d564049e2dbaae41c3f86997a679dcf847
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 2.8.6
2
+ ---------
3
+
4
+ - Fix string/byte encoding issue when unicode characters present. Reported by @foxban. This was also backported to v2.7.12. [#120]
5
+
1
6
  2.8.5
2
7
  ----------
3
8
 
@@ -35,6 +40,11 @@
35
40
  - No longer creating `-java` platform gem due to removal of c++ compiler.
36
41
  - Added WTFPL license.
37
42
 
43
+ 2.7.12
44
+ -----------
45
+
46
+ - Backport string/byte encoding issue when unicode characters present. [code: #122, original issue: #120]
47
+
38
48
  2.0.0
39
49
  -----------
40
50
 
@@ -18,8 +18,9 @@ module Protobuf
18
18
  end
19
19
 
20
20
  def decode(bytes)
21
- bytes.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
22
- bytes
21
+ bytes_to_decode = bytes.dup
22
+ bytes_to_decode.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
23
+ bytes_to_decode
23
24
  end
24
25
 
25
26
  def define_setter
@@ -46,11 +47,12 @@ module Protobuf
46
47
  end
47
48
 
48
49
  def encode(value)
49
- value = value.encode if value.is_a?(::Protobuf::Message)
50
- value.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
50
+ value_to_encode = value.dup
51
+ value_to_encode = value.encode if value.is_a?(::Protobuf::Message)
52
+ value_to_encode.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
51
53
 
52
- string_size = ::Protobuf::Field::VarintField.encode(value.size)
53
- string_size << value
54
+ string_size = ::Protobuf::Field::VarintField.encode(value_to_encode.size)
55
+ string_size << value_to_encode
54
56
  end
55
57
 
56
58
  def wire_type
@@ -6,18 +6,19 @@ module Protobuf
6
6
  ENCODING = 'UTF-8'.freeze
7
7
 
8
8
  def decode(bytes)
9
- bytes.force_encoding(::Protobuf::Field::StringField::ENCODING)
10
- bytes
9
+ bytes_to_decode = bytes.dup
10
+ bytes_to_decode.force_encoding(::Protobuf::Field::StringField::ENCODING)
11
+ bytes_to_decode
11
12
  end
12
13
 
13
14
  # TODO: make replace character configurable?
14
15
  def encode(value)
15
- value = value.dup if value.frozen?
16
- value.encode!(::Protobuf::Field::StringField::ENCODING, :invalid => :replace, :undef => :replace, :replace => "")
17
- value.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
16
+ value_to_encode = value.dup
17
+ value_to_encode.encode!(::Protobuf::Field::StringField::ENCODING, :invalid => :replace, :undef => :replace, :replace => "")
18
+ value_to_encode.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
18
19
 
19
- string_size = ::Protobuf::Field::VarintField.encode(value.size)
20
- string_size << value
20
+ string_size = ::Protobuf::Field::VarintField.encode(value_to_encode.size)
21
+ string_size << value_to_encode
21
22
  end
22
23
  end
23
24
  end
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.8.5'
2
+ VERSION = '2.8.6'
3
3
  PROTOC_VERSION = '2.5.0'
4
4
  end
@@ -1,6 +1,9 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ::Protobuf::Field::StringField do
6
+
4
7
  describe '#encode' do
5
8
  context 'when a repeated string field contains frozen strings' do
6
9
  it 'does not raise an encoding error' do
@@ -19,5 +22,25 @@ describe ::Protobuf::Field::StringField do
19
22
  }.not_to raise_error
20
23
  end
21
24
  end
25
+
26
+ it 'does not alter string values after encoding multiple times' do
27
+ source_string = "foo"
28
+ proto = ::Test::Resource.new(:name => source_string)
29
+ proto.encode
30
+ proto.name.should eq source_string
31
+ proto.encode
32
+ proto.name.should eq source_string
33
+ end
34
+
35
+ it 'does not alter unicode string values after encoding multiple times' do
36
+ source_string = "¢"
37
+ proto = ::Test::Resource.new(:name => source_string)
38
+ proto.encode
39
+ proto.name.should eq source_string
40
+ proto.encode
41
+ proto.name.should eq source_string
42
+ end
22
43
  end
44
+
45
+
23
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.5
4
+ version: 2.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-10 00:00:00.000000000 Z
13
+ date: 2013-09-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -366,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
366
366
  version: '0'
367
367
  requirements: []
368
368
  rubyforge_project:
369
- rubygems_version: 2.0.2
369
+ rubygems_version: 2.1.2
370
370
  signing_key:
371
371
  specification_version: 4
372
372
  summary: Google Protocol Buffers serialization and RPC implementation for Ruby.