logtail-rack 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: a63714ec66ecfdd4a4db3ffc637fe1b02da37422789fc7ea8617474b63f90367
4
- data.tar.gz: 8fedbde00ed676731409c299e7e5183bc24daa049f21e9e5ffd7995706bc2dda
3
+ metadata.gz: 43f0b7693831d0097e1496ba79258afc7b8b7cda69d805fa99248cbc79812181
4
+ data.tar.gz: 23bdde6dc4a16420b3f8604edc3266775b248e2a51177be01c64a314577612d9
5
5
  SHA512:
6
- metadata.gz: 3bc10f2ad042d60da36ea8491f214764028e045bde28db87fb68fb7de32278fe98ddf84105deda98a07cfdfb7e9ee9ffaf46056093fa670dd35043fb2d48d69a
7
- data.tar.gz: 437553fcaf79354dcb76bef63bca8c58cb1dcd8c7972f3f0204bd7c2b2aad30e0943776b78de0b307a9148643cb2974a6d5b3fc2f7a7d31b80bfc3e4d0243177
6
+ metadata.gz: f9dc63f41ea21c4f31360608d82ec1cbf6652cac1774a28695a845a36858a95215ee24d49696278f07267266922659559cee8790a85767e64cd143e833232950
7
+ data.tar.gz: c1faf9719cac776039dac04d3acc9b91b9520f9f7983a4db242344e9f66cfedd37feb0bfe8b6575185b883918e45b37eaf76a61708f364dd627a8805349f6989
@@ -1,6 +1,7 @@
1
1
  require "logtail/contexts/http"
2
2
  require "logtail/current_context"
3
3
  require "logtail-rack/middleware"
4
+ require "logtail-rack/util/encoding"
4
5
  require "logtail-rack/util/request"
5
6
 
6
7
  module Logtail
@@ -11,10 +12,10 @@ module Logtail
11
12
  def call(env)
12
13
  request = Util::Request.new(env)
13
14
  context = Contexts::HTTP.new(
14
- host: request.host.force_encoding('UTF-8'),
15
- method: request.request_method.force_encoding('UTF-8'),
15
+ host: Util::Encoding.force_utf8_encoding(request),
16
+ method: Util::Encoding.force_utf8_encoding(request.request_method),
16
17
  path: request.path,
17
- remote_addr: request.ip.force_encoding('UTF-8'),
18
+ remote_addr: Util::Encoding.force_utf8_encoding(request.ip),
18
19
  request_id: request.request_id
19
20
  )
20
21
 
@@ -6,6 +6,7 @@ require "logtail/current_context"
6
6
  require "logtail-rack/http_request"
7
7
  require "logtail-rack/http_response"
8
8
  require "logtail-rack/middleware"
9
+ require "logtail-rack/util/encoding"
9
10
 
10
11
  module Logtail
11
12
  module Integrations
@@ -179,13 +180,13 @@ module Logtail
179
180
  body: event_body,
180
181
  content_length: safe_to_i(request.content_length),
181
182
  headers: filter_http_headers(request.headers),
182
- host: force_encoding(request.host),
183
+ host: Util::Encoding.force_utf8_encoding(request.host),
183
184
  method: request.request_method,
184
185
  path: request.path,
185
186
  port: request.port,
186
- query_string: force_encoding(request.query_string),
187
+ query_string: Util::Encoding.force_utf8_encoding(request.query_string),
187
188
  request_id: request.request_id,
188
- scheme: force_encoding(request.scheme),
189
+ scheme: Util::Encoding.force_utf8_encoding(request.scheme),
189
190
  )
190
191
 
191
192
  {
@@ -277,14 +278,6 @@ module Logtail
277
278
  def safe_to_i(val)
278
279
  val.nil? ? nil : val.to_i
279
280
  end
280
-
281
- def force_encoding(value)
282
- if value.respond_to?(:force_encoding)
283
- value.dup.force_encoding('UTF-8')
284
- else
285
- value
286
- end
287
- end
288
281
  end
289
282
  end
290
283
  end
@@ -3,7 +3,10 @@ module Logtail
3
3
  class Encoding
4
4
  def self.force_utf8_encoding(data)
5
5
  if data.respond_to?(:force_encoding)
6
- data.dup.force_encoding('UTF-8')
6
+ encoded_data = data.dup.force_encoding('UTF-8')
7
+ encoded_data = data.dup.force_encoding("ISO-8859-1").encode("UTF-8") unless encoded_data.valid_encoding?
8
+ encoded_data = data.dup.encode('UTF-8', invalid: :replace, undef: :replace) unless encoded_data.valid_encoding?
9
+ encoded_data
7
10
  elsif data.respond_to?(:transform_values)
8
11
  data.transform_values { |val| Logtail::Util::Encoding.force_utf8_encoding(val) }
9
12
  else
@@ -1,7 +1,7 @@
1
1
  module Logtail
2
2
  module Integrations
3
3
  module Rack
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logtail-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Logtail
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-14 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logtail
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.3.7
139
+ rubygems_version: 3.3.3
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Logtail integration for Rack