lib/em-websocket/handshake76.rb in em-websocket-0.5.0 vs lib/em-websocket/handshake76.rb in em-websocket-0.5.1
- old
+ new
@@ -37,9 +37,13 @@
third
Digest::MD5.digest(sum)
end
def numbers_over_spaces(string)
+ unless string
+ raise HandshakeError, "WebSocket key1 or key2 is missing"
+ end
+
numbers = string.scan(/[0-9]/).join.to_i
spaces = string.scan(/ /).size
# As per 5.2.5, abort the connection if spaces are zero.
raise HandshakeError, "Websocket Key1 or Key2 does not contain spaces - this is a symptom of a cross-protocol attack" if spaces == 0