airbrake-ruby 1.2.3 → 1.2.4

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: 7584737ab96d10454a892c2a5962f71efa1f344b
4
- data.tar.gz: 0b0b806ab0434e86f0ad797854679e53480997d7
3
+ metadata.gz: 3dca16a0676d8aa679ffb3980107107697027b4e
4
+ data.tar.gz: bfb64410f23a9f6f37047bc9baad6147c25f874e
5
5
  SHA512:
6
- metadata.gz: 5a1891009204e5d5dbca417495d270eabab1340a7059f106430a1c50c5de0f41647f864defd0ce9642fa06d9b4e0425aa81c908925c024e860f45148e7773832
7
- data.tar.gz: 39bae0e2ac392cb11ea1d55b3a8ae2dd7d513fba0dcd6e7908af4bcc8c962360d7a76a8ce9fe4c3d2d9c1dc5de87c69cf34bbdd4d541a943df96b1a7719de0a4
6
+ metadata.gz: 0adab3693e3ea82b617927c3efddc5d85ded45be062d849c27e4090c06a5099647449e182c8a945c5e055fc79d2a609b42d08d77a28d989f94b94feaec55ae97
7
+ data.tar.gz: 3034cfdedfb4320732413e948736dfe6982323859ef109bbcec4044047bb10cce88421a862c67156939c713b7a42ec839581f9c5d64120f853e74d82dd35c60d
@@ -91,7 +91,7 @@ module Airbrake
91
91
  end
92
92
 
93
93
  def truncate_string(str)
94
- replace_invalid_characters!(str)
94
+ str = replace_invalid_characters!(str)
95
95
  return str if str.length <= @max_size
96
96
  str.slice(0, @max_size) + '[Truncated]'.freeze
97
97
  end
@@ -106,14 +106,16 @@ module Airbrake
106
106
  # For modern Rubies we use UTF-16 as a safe alternative.
107
107
  #
108
108
  # @param [String] str The string to replace characters
109
- # @return [void]
110
- # @note This method mutates +str+ for speed
109
+ # @return [String] a UTF-8 encoded string
110
+ # @note This method mutates +str+ unless it's frozen,
111
+ # in which case it creates a duplicate
111
112
  # @see https://github.com/flori/json/commit/3e158410e81f94dbbc3da6b7b35f4f64983aa4e3
112
113
  def replace_invalid_characters!(str)
113
114
  encoding = str.encoding
114
115
  utf8_string = (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII)
115
116
  return str if utf8_string && str.valid_encoding?
116
117
 
118
+ str = str.dup if str.frozen?
117
119
  str.encode!(TEMP_ENCODING, ENCODING_OPTIONS) if utf8_string
118
120
  str.encode!('utf-8', ENCODING_OPTIONS)
119
121
  end
@@ -3,5 +3,5 @@
3
3
  module Airbrake
4
4
  ##
5
5
  # @return [String] the library version
6
- AIRBRAKE_RUBY_VERSION = '1.2.3'.freeze
6
+ AIRBRAKE_RUBY_VERSION = '1.2.4'.freeze
7
7
  end
@@ -445,6 +445,17 @@ RSpec.describe Airbrake::PayloadTruncator do
445
445
 
446
446
  expect(params[:unicode]).to match(/[�\?]{4}/)
447
447
  end
448
+
449
+ it "doesn't fail when string is frozen" do
450
+ encoded = Base64.encode64("\xD3\xE6\xBC\x9D\xBA").encode!('ASCII-8BIT')
451
+ bad_string = Base64.decode64(encoded).freeze
452
+
453
+ params = { unicode: bad_string }
454
+
455
+ @truncator.truncate_object(params)
456
+
457
+ expect(params[:unicode]).to match(/[�\?]{4}/)
458
+ end
448
459
  end
449
460
  end
450
461
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-22 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec