timber 2.0.23 → 2.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcda9ae1986cc2ba1cc86941ab161e98cbf87267
4
- data.tar.gz: 0dd221e5f41253700dc08a47edd24c9d5097ff6c
3
+ metadata.gz: 8c631daf0393857de501da9e12c1087f4f6cceda
4
+ data.tar.gz: 55b336aec1471657a0358d80e7bfabdd1c6a7a1b
5
5
  SHA512:
6
- metadata.gz: e11eff7209118ea8b0e0731e80ec3e1c24deed610a17eddc13d6becd282c66f906fc5cf48dd065ec07df41d2d174273c6695aaea903110d6fa7e29e8b1fe11ee
7
- data.tar.gz: 163e16d153963b5e2d13ce2da63ff70c3158bfd70f7c29f04a72ea6bf5cecb2d5d50380bf70a83cb10a23344c249d125816db574a864b6170d3709a214fb6d2a
6
+ metadata.gz: 706a67aec83bf76c5a2089c3d7ca14b15226a05fd3113a4896cc0faec27ba7976c439783e7a3f50367ec38e7cbacf9c7611a8e493a4faadfcdc3356610df5634
7
+ data.tar.gz: c4e70b7199e075ce052593fe0a4d9c12cb83e2ecd0599fbb3188f939d6b234517e07f50d32f7c0daaf0f5a92a635b355830560044d7407de45e57fdf9511bd56
@@ -3,6 +3,7 @@ module Timber
3
3
  module HTTPEvent
4
4
  AUTHORIZATION_HEADER = 'authorization'.freeze
5
5
  QUERY_STRING_LIMIT = 5_000.freeze
6
+ STRING_CLASS_NAME = 'String'.freeze
6
7
 
7
8
  extend self
8
9
 
@@ -26,9 +27,23 @@ module Timber
26
27
  if headers.is_a?(::Hash)
27
28
  h = headers.each_with_object({}) do |(k, v), h|
28
29
  # Force the header into a valid UTF-8 string, otherwise we will encounter
29
- # encoding issues when we convert this data to json. Moreoever, if the
30
+ # encoding issues when we serialize this data. Moreoever, if the
30
31
  # data is already valid UTF-8 we don't pay a penalty.
31
- h[k] = v && Timber::Util::String.normalize_to_utf8(v)
32
+ #
33
+ # Note: we compare the class name because...
34
+ #
35
+ # string = 'my string'.force_encoding('ASCII-8BIT')
36
+ # string.is_a?(String) => false
37
+ # string.class => String
38
+ # string.class == String => false
39
+ # string.class.name == "String" => true
40
+ #
41
+ # ¯\_(ツ)_/¯
42
+ if v.class.name == STRING_CLASS_NAME
43
+ h[k] = Timber::Util::String.normalize_to_utf8(v)
44
+ else
45
+ h[k] = v
46
+ end
32
47
  end
33
48
 
34
49
  keys_to_sanitize = [AUTHORIZATION_HEADER] + (Config.instance.header_filters || [])
@@ -9,7 +9,7 @@ module Timber
9
9
  if string.encoding.to_s == UTF8
10
10
  string
11
11
  else
12
- string.encode('UTF-8', {
12
+ string.encode(UTF8, {
13
13
  :invalid => :replace,
14
14
  :undef => :replace,
15
15
  :replace => '?'
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "2.0.23"
2
+ VERSION = "2.0.24"
3
3
  end
@@ -6,5 +6,10 @@ describe Timber::Util::HTTPEvent, :rails_23 => true do
6
6
  result = described_class.normalize_headers({"key" => nil})
7
7
  expect(result).to eq({"key" => nil})
8
8
  end
9
+
10
+ it "should handle non strings" do
11
+ result = described_class.normalize_headers({"key" => 1})
12
+ expect(result).to eq({"key" => 1})
13
+ end
9
14
  end
10
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.23
4
+ version: 2.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-25 00:00:00.000000000 Z
11
+ date: 2017-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack