Skip to content

Commit e3b749e

Browse files
committedMay 13, 2024
fix 4 autobahn tests
use pull_request_target for autobahn workflow
1 parent 388fe56 commit e3b749e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed
 

‎.github/workflows/autobahn.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Autobahn
22
on:
33
workflow_dispatch:
44

5-
pull_request:
5+
pull_request_target:
66
paths:
77
- '.github/workflows/autobahn.yml'
88
- 'lib/web/websocket/**'
@@ -54,7 +54,7 @@ jobs:
5454
run: npm run test:websocket:autobahn:report
5555

5656
- name: Generate Report for PR Comment
57-
if: github.event_name == 'pull_request'
57+
if: github.event_name == 'pull_request_target'
5858
id: report-markdown
5959
run: |
6060
echo "comment<<nEOFn" >> $GITHUB_OUTPUT
@@ -64,7 +64,7 @@ jobs:
6464
REPORTER: markdown
6565

6666
- name: Comment PR
67-
if: github.event_name == 'pull_request'
67+
if: github.event_name == 'pull_request_target'
6868
uses: thollander/actions-comment-pull-request@v2
6969
with:
7070
message: ${{ steps.report-markdown.outputs.comment }}

‎lib/web/websocket/receiver.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class ByteParser extends Writable {
110110

111111
if (isControlFrame(opcode)) {
112112
const loop = this.parseControlFrame(callback, {
113+
header: buffer,
113114
opcode,
114115
fragmented,
115116
payloadLength
@@ -122,6 +123,7 @@ class ByteParser extends Writable {
122123
}
123124
} else if (isContinuationFrame(opcode)) {
124125
const loop = this.parseContinuationFrame(callback, {
126+
header: buffer,
125127
fin,
126128
fragmented,
127129
payloadLength
@@ -297,7 +299,7 @@ class ByteParser extends Writable {
297299
* Parses control frames.
298300
* @param {Buffer} data
299301
* @param {(err?: Error) => void} callback
300-
* @param {{ opcode: number, fragmented: boolean, payloadLength: number }} info
302+
* @param {{ opcode: number, fragmented: boolean, payloadLength: number, header: Buffer }} info
301303
*/
302304
parseControlFrame (callback, info) {
303305
assert(!info.fragmented)
@@ -307,6 +309,9 @@ class ByteParser extends Writable {
307309
failWebsocketConnection(this.ws, 'Payload length for control frame exceeded 125 bytes.')
308310
return false
309311
} else if (this.#byteOffset < info.payloadLength) {
312+
this.#buffers.unshift(info.header)
313+
this.#byteOffset += 2
314+
310315
callback()
311316
return false
312317
}
@@ -405,14 +410,17 @@ class ByteParser extends Writable {
405410
* Parses continuation frames.
406411
* @param {Buffer} data
407412
* @param {(err?: Error) => void} callback
408-
* @param {{ fin: boolean, fragmented: boolean, payloadLength: number }} info
413+
* @param {{ fin: boolean, fragmented: boolean, payloadLength: number, header: Buffer }} info
409414
*/
410415
parseContinuationFrame (callback, info) {
411416
// If we received a continuation frame before we started parsing another frame.
412417
if (this.#info.opcode === undefined) {
413418
failWebsocketConnection(this.ws, 'Received unexpected continuation frame.')
414419
return false
415420
} else if (this.#byteOffset < info.payloadLength) {
421+
this.#buffers.unshift(info.header)
422+
this.#byteOffset += 2
423+
416424
callback()
417425
return false
418426
}

0 commit comments

Comments
 (0)