websocket-driver 0.7.4 → 0.7.5

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: 91c58586ddd290ad5d320267e36706bdbcffb09c7ba5300d6c3fcd50f342ec2f
4
- data.tar.gz: 7f5afd33de5b0c0e68d7d4cbab726e7ada8200f1b5916e01feb6a3508e3f3e51
3
+ metadata.gz: 046c514660d2c0dab2cf42bce8314a17e713909377a5da470beaeadf666ff28e
4
+ data.tar.gz: 9830c412394044d102dd6f313346721076ef0f97284d6182aeb06862e1f427b2
5
5
  SHA512:
6
- metadata.gz: 92ececf04fb09b31c8fd1617a38351d7a04c4306f3a27b7061e1220710a5a703da162ca0b47ee2fbdf63e20606040a022de61c51c651add2356665526adffe46
7
- data.tar.gz: f89d71520719be104eb649c318ca85bdd107ec875a62405061fe0268d9df08b0487fe333c531d4635950245ef2879c9fc43c8a148a63afc97f508f28cc4c7397
6
+ metadata.gz: cea4027f342f51a688c8004a92ca29b68af9a9395b5e7f8d2462b8742067862718d23f4be9ca6162f761774490e4cdf33111bb746f9221d5acace6546a749b35
7
+ data.tar.gz: d124aa6acf1cbfa498b44d02d6aa659c99e97e177441e8cbd43958db38c6cf03d703d26ae73998a09719c0612f538554049d58b58aa8cc8ab5f0bb458e27c988
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.7.5 / 2021-06-12
2
+
3
+ - Do not change the encoding of strings passed to `Driver#text`
4
+
1
5
  ### 0.7.4 / 2021-05-24
2
6
 
3
7
  - Optimise conversions between strings and byte arrays and related encoding
@@ -115,7 +115,7 @@ module WebSocket
115
115
  end
116
116
 
117
117
  def text(message)
118
- message = message.encode(Encoding::UTF_8) unless message.encoding == Encoding::UTF_8
118
+ message = Driver.encode(message, Encoding::UTF_8)
119
119
  frame(message, :text)
120
120
  end
121
121
 
@@ -194,19 +194,19 @@ module WebSocket
194
194
  end
195
195
  end
196
196
 
197
- def self.encode(string, encoding = nil)
198
- case string
199
- when Array then
200
- string = string.pack('C*')
201
- encoding ||= Encoding::BINARY
202
- when String then
203
- encoding ||= Encoding::UTF_8
197
+ def self.encode(data, encoding = nil)
198
+ if Array === data
199
+ encoding ||= Encoding::BINARY
200
+ return data.pack('C*').force_encoding(encoding)
204
201
  end
205
- unless string.encoding == encoding
206
- string = string.dup if string.frozen?
207
- string.force_encoding(encoding)
208
- end
209
- string
202
+
203
+ encoding ||= Encoding::UTF_8
204
+
205
+ return data if data.encoding == encoding
206
+ return data.encode(encoding) unless data.encoding == Encoding::BINARY
207
+
208
+ data = data.dup if data.frozen?
209
+ data.force_encoding(encoding)
210
210
  end
211
211
 
212
212
  def self.validate_options(options, valid_keys)
@@ -164,7 +164,7 @@ module WebSocket
164
164
  message.rsv1 = message.rsv2 = message.rsv3 = false
165
165
  message.opcode = OPCODES[type || (String === buffer ? :text : :binary)]
166
166
 
167
- payload = Driver.encode(buffer, Encoding::BINARY)
167
+ payload = Driver.encode(buffer)
168
168
  payload = [code, payload].pack('S>a*') if code
169
169
  message.data = payload
170
170
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-24 00:00:00.000000000 Z
11
+ date: 2021-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket-extensions