From e3b749eb2f245a9762f944c4ca42b905439e64cd Mon Sep 17 00:00:00 2001 From: Khafra Date: Mon, 13 May 2024 10:48:01 -0400 Subject: [PATCH] fix 4 autobahn tests use pull_request_target for autobahn workflow --- .github/workflows/autobahn.yml | 6 +++--- lib/web/websocket/receiver.js | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/autobahn.yml b/.github/workflows/autobahn.yml index 27e0c67f25f..504bda3b4be 100644 --- a/.github/workflows/autobahn.yml +++ b/.github/workflows/autobahn.yml @@ -2,7 +2,7 @@ name: Autobahn on: workflow_dispatch: - pull_request: + pull_request_target: paths: - '.github/workflows/autobahn.yml' - 'lib/web/websocket/**' @@ -54,7 +54,7 @@ jobs: run: npm run test:websocket:autobahn:report - name: Generate Report for PR Comment - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' id: report-markdown run: | echo "comment<> $GITHUB_OUTPUT @@ -64,7 +64,7 @@ jobs: REPORTER: markdown - name: Comment PR - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' uses: thollander/actions-comment-pull-request@v2 with: message: ${{ steps.report-markdown.outputs.comment }} diff --git a/lib/web/websocket/receiver.js b/lib/web/websocket/receiver.js index 66f7a3e8f64..809fa657a29 100644 --- a/lib/web/websocket/receiver.js +++ b/lib/web/websocket/receiver.js @@ -110,6 +110,7 @@ class ByteParser extends Writable { if (isControlFrame(opcode)) { const loop = this.parseControlFrame(callback, { + header: buffer, opcode, fragmented, payloadLength @@ -122,6 +123,7 @@ class ByteParser extends Writable { } } else if (isContinuationFrame(opcode)) { const loop = this.parseContinuationFrame(callback, { + header: buffer, fin, fragmented, payloadLength @@ -297,7 +299,7 @@ class ByteParser extends Writable { * Parses control frames. * @param {Buffer} data * @param {(err?: Error) => void} callback - * @param {{ opcode: number, fragmented: boolean, payloadLength: number }} info + * @param {{ opcode: number, fragmented: boolean, payloadLength: number, header: Buffer }} info */ parseControlFrame (callback, info) { assert(!info.fragmented) @@ -307,6 +309,9 @@ class ByteParser extends Writable { failWebsocketConnection(this.ws, 'Payload length for control frame exceeded 125 bytes.') return false } else if (this.#byteOffset < info.payloadLength) { + this.#buffers.unshift(info.header) + this.#byteOffset += 2 + callback() return false } @@ -405,7 +410,7 @@ class ByteParser extends Writable { * Parses continuation frames. * @param {Buffer} data * @param {(err?: Error) => void} callback - * @param {{ fin: boolean, fragmented: boolean, payloadLength: number }} info + * @param {{ fin: boolean, fragmented: boolean, payloadLength: number, header: Buffer }} info */ parseContinuationFrame (callback, info) { // If we received a continuation frame before we started parsing another frame. @@ -413,6 +418,9 @@ class ByteParser extends Writable { failWebsocketConnection(this.ws, 'Received unexpected continuation frame.') return false } else if (this.#byteOffset < info.payloadLength) { + this.#buffers.unshift(info.header) + this.#byteOffset += 2 + callback() return false }