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 +4 -4
- data/lib/nebulous_stomp/msg/body.rb +16 -12
- data/lib/nebulous_stomp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37e0259753ea592ddf7b7423f2a76c1b621fe559
|
4
|
+
data.tar.gz: e950e016aade0dbc078010b7b39d1a685e82561b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
@
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
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.
|
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
|
-
|
179
|
-
|
180
|
-
|
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
|
|