websocket-driver 0.8.0 → 0.8.1

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
  SHA256:
3
- metadata.gz: c1f212eb47e19ec359d90624302280cfc94d6fbc9d4bf9a419574fa8531c7d38
4
- data.tar.gz: a35ae8ecae5b94d297141eb9bc0f29647614034cc961bc8c4e26a7876aa40a4b
3
+ metadata.gz: 29e86447ce1bcb8a90f93a8d93b8a80322f3c36e655f9a1a4e32415eddaeb129
4
+ data.tar.gz: 07c2dccd9d940048a1be5f8459f2c0d3214762f4bdd28f2096406e4df7725184
5
5
  SHA512:
6
- metadata.gz: 0dd79a8fd32a6380ef832549c1139b1f425f0fe49b33adb32338ce39d5ad9d1d558ce1f33f89c3fefa8464b65a0b9d9664e509e200c55979add09b0cd872e55d
7
- data.tar.gz: 87684980b91fb5d6cf1ae8866ab51cd60809fbbba4d90032585c8596797333e8e0e995f1b98cb7269e917de2c501ee524d0c2ff72917457092fa292e51e7e0a9
6
+ metadata.gz: 105e1d610de90d7b934b88ce141b1aff0496afc22b2599b56d046304b09c9476a122e0eb04f8cddc5303d6f38204334ad2b36113c46d28fbbb486292870eb870
7
+ data.tar.gz: 63e4ab5cd1ffadd35797b0dd713b5a3da3e6eed3e8c3cf09b0ebff18d7e3c931c6ed2b45e992dc26cf77a96e5a8be349318bcafe51bd80498ae389dc8a0f9d9f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 0.8.1 / 2026-06-04
2
+
3
+ - Close a draft-75/76 connection if a length header grows to exceed the
4
+ configured max length
5
+ - Fail the connection if a message is larger than the configured max length
6
+ after extension processing
7
+ - Limit the total HTTP request line and headers size to 32K
8
+
1
9
  ### 0.8.0 / 2025-05-25
2
10
 
3
11
  - Emit binary message as a string with `Encoding::BINARY` instead of an array
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2010-2025 James Coglan
1
+ Copyright 2010-2026 James Coglan
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -41,6 +41,7 @@ module WebSocket
41
41
 
42
42
  when 1 then
43
43
  @length = (octet & 0x7F) + 128 * @length
44
+ return close if @length > @max_length
44
45
 
45
46
  if @closing and @length.zero?
46
47
  return close
@@ -400,6 +400,10 @@ module WebSocket
400
400
 
401
401
  payload = message.data
402
402
 
403
+ if payload.bytesize > @max_length
404
+ return fail(:too_large, 'WebSocket frame length too large')
405
+ end
406
+
403
407
  case message.opcode
404
408
  when OPCODES[:text] then
405
409
  payload = Driver.encode(payload, Encoding::UTF_8)
@@ -2,7 +2,7 @@ module WebSocket
2
2
  module HTTP
3
3
 
4
4
  module Headers
5
- MAX_LINE_LENGTH = 4096
5
+ MAX_REQUEST_SIZE = 32768
6
6
  CR = 0x0D
7
7
  LF = 0x0A
8
8
 
@@ -38,6 +38,7 @@ module WebSocket
38
38
  attr_reader :headers
39
39
 
40
40
  def initialize
41
+ @size = 0
41
42
  @buffer = []
42
43
  @env = {}
43
44
  @headers = {}
@@ -54,6 +55,9 @@ module WebSocket
54
55
 
55
56
  def parse(chunk)
56
57
  chunk.each_byte do |octet|
58
+ @size += 1
59
+ return error if @size > MAX_REQUEST_SIZE
60
+
57
61
  if octet == LF and @stage < 2
58
62
  @buffer.pop if @buffer.last == CR
59
63
  if @buffer.empty?
@@ -71,9 +75,8 @@ module WebSocket
71
75
  end
72
76
  end
73
77
  @buffer = []
74
- else
75
- @buffer << octet if @stage >= 0
76
- error if @stage < 2 and @buffer.size > MAX_LINE_LENGTH
78
+ elsif @stage >= 0
79
+ @buffer << octet
77
80
  end
78
81
  end
79
82
  @env['rack.input'] = StringIO.new(string_buffer)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.6.7
150
+ rubygems_version: 3.6.9
151
151
  specification_version: 4
152
152
  summary: WebSocket protocol handler with pluggable I/O
153
153
  test_files: []