Skip to content

Fix notice when verifying empty request URI - #78

Merged
clue merged 1 commit into
ratchetphp:masterfrom
clue-labs:empty-request-uri
Jun 6, 2026
Merged

Fix notice when verifying empty request URI#78
clue merged 1 commit into
ratchetphp:masterfrom
clue-labs:empty-request-uri

Conversation

@clue

@clue clue commented May 31, 2026

Copy link
Copy Markdown
Member

This changeset avoids a PHP notice when verifying a request with an empty request URI. An empty URI was already rejected as invalid, but reading the first character to check for a leading slash triggered an "Uninitialized string offset" notice before returning. An empty string is now rejected up front.

Closes #74

@clue clue added this to the 0.4.1 milestone May 31, 2026
@clue clue added the bug label May 31, 2026
@clue
clue requested a review from Copilot June 1, 2026 09:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a PHP notice (Uninitialized string offset: 0) triggered when validating an empty request URI path during WebSocket handshake verification (RFC6455), by explicitly rejecting empty strings before checking the leading slash.

Changes:

  • Reject empty request URIs up front in RequestVerifier::verifyRequestURI() to avoid string-offset access on ''.
  • Add a unit test case asserting an empty URI is invalid.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Handshake/RequestVerifier.php Adds an early '' guard before accessing $val[0], preventing notices while preserving invalidation behavior.
tests/unit/Handshake/RequestVerifierTest.php Extends the request URI data provider with an empty-string case to cover the regression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@clue
clue merged commit 9b05f37 into ratchetphp:master Jun 6, 2026
14 checks passed
@clue
clue deleted the empty-request-uri branch June 6, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP Notice: Uninitialized string offset: 0 RequestVerifier.php on line 56

2 participants