nebulous_stomp 3.0.7 → 3.0.8

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: 53153cf352f2c866e92f780540a077aa72cdd1b5
4
- data.tar.gz: 6804ad691e2863f8b403563c962b2de1f5e73bf4
3
+ metadata.gz: 37e0259753ea592ddf7b7423f2a76c1b621fe559
4
+ data.tar.gz: e950e016aade0dbc078010b7b39d1a685e82561b
5
5
  SHA512:
6
- metadata.gz: ee8d27f2fc80b9c32a12c22eea38e39b7281136575daca91c61adb4c7cf63ac9cd4249777a4081d5b0b6c08f14d441634902c5ae077ae3054f0d5422c676416e
7
- data.tar.gz: 6c02255538ec06fccf4829307944c4c2f7f9bc441060dcfaabd4d424c1376cf2cfb879348ad58bc20b8b0cbe7f9fd2abb5cdf8f6e77ec82d74772e3b2a928a0c
6
+ metadata.gz: 84c92a22e5bdb5574bc7e7336e5c0f3577d3360e7eaadff4bd2b5ddedcc4ba12be1aa401d53859588d9cfbb4d51ba3968912f625f7bb7c560bc1aaba91e46ccc
7
+ data.tar.gz: e03c089d8d140125a4f1a124537014fbb1e36d1167ece86b4e0c99956d0069e77d4add4f485f2d8cb5389d2d523c3288be6a3c174e19a6b22151ad09e9fab633
@@ -27,7 +27,7 @@ module NebulousStomp
27
27
  #
28
28
  def initialize(is_json, hash)
29
29
  @is_json = !!is_json
30
- @stomp_body = hash[:stompBody]
30
+ @stomp_body = fix_bad_encoding( hash[:stompBody] )
31
31
  @body = hash[:body]
32
32
  @verb = hash[:verb]
33
33
  @params = hash[:parameters] || hash[:params]
@@ -35,11 +35,10 @@ module NebulousStomp
35
35
 
36
36
  fill_from_stomp
37
37
 
38
- @stomp_body = fix_bad_encoding(@stomp_body)
39
- @body = fix_bad_encoding(@body)
40
- @verb = fix_bad_encoding(@verb)
41
- @params = fix_bad_encoding(@params)
42
- @desc = fix_bad_encoding(@desc)
38
+ @body = fix_bad_encoding(@body)
39
+ @verb = fix_bad_encoding(@verb)
40
+ @params = fix_bad_encoding(@params)
41
+ @desc = fix_bad_encoding(@desc)
43
42
  end
44
43
 
45
44
  ##
@@ -169,18 +168,23 @@ module NebulousStomp
169
168
  end
170
169
 
171
170
  ##
172
- # Deal with encoding problems. Try ISO8859-1 first. (Sorry for the Western bias, but this
173
- # solves a lot of use-cases for us.)
171
+ # Deal with encoding problems.
174
172
  #
175
173
  def fix_bad_encoding(string)
176
174
  return string unless string.is_a? String
177
175
 
178
- unless string.valid_encoding?
179
- s = string.encode("UTF-8", "ISO8859-1")
180
- string = s if s.valid_encoding?
176
+ # Assume that anything without a real encoding is actually in ISO8859-1, and convert it to
177
+ # UTF-8. (Sorry for the UK bias, but this fixes problems for us here. Eventually I'd like
178
+ # to see an an optional encoding set against each target, but that's for another day.)
179
+ if string.encoding == Encoding::ASCII_8BIT
180
+ string.force_encoding("ISO8859-1")
181
+ string.encode!("UTF-8", invalid: :replace, undef: :replace)
182
+
183
+ # Otherwise if there are problems don't screw with the encoding, but do fix the problems.
184
+ elsif !string.valid_encoding?
185
+ string.encode!(invalid: :replace, undef: :replace)
181
186
  end
182
187
 
183
- string.encode!(invalid: :replace, undef: :replace) unless string.valid_encoding?
184
188
  string
185
189
  end
186
190
 
@@ -1,5 +1,5 @@
1
1
  module NebulousStomp
2
2
 
3
3
  # Nebulous version number
4
- VERSION = "3.0.7"
4
+ VERSION = "3.0.8"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nebulous_stomp
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jones