Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request addresses a bug in the
IsRequestURIfunction where it incorrectly validates strings like"foobar.com"astrue, despite them not being valid HTTP request URIs per RFC 3986 and HTTP expectations. The change targets themasterbranch as it’s a bugfix.Bug Details
Are you fixing a bug or providing a failing unit test to demonstrate a bug?
TestIsRequestURI.How do you reproduce it?
go test -v -run TestIsRequestURI. The test case for"foobar.com"expectsfalsebut getstruewith the current implementation:{"foobar.com", false},What did you expect to happen?
IsRequestURI("foobar.com")should returnfalsebecause it’s neither an absolute URI (e.g.,http://foobar.com) nor an absolute path (e.g.,/foobar), and it doesn’t qualify as a valid relative path in an HTTP request context without a scheme or leading slash.What actually happened?
url.ParseRequestURI, which is too permissive and accepts"foobar.com"as a valid opaque URI, returningtrue. This caused the test to fail with:Changes Made
IsRequestURIto:url.Parseinstead ofurl.ParseRequestURIfor broader parsing.http://)./).rel/test/dir,./rel/test/dir)."foobar.com")."foobar.com"returnsfalsewhile preserving correct behavior for other valid cases.Testing
go test -v -run TestIsRequestURI, and the test case for"foobar.com"now passes.go test -v) to confirm no regressions.Why This Change is Necessary
IsRequestURIto misclassify invalid HTTP request URIs, potentially leading to incorrect validation in applications relying on this function. This fix aligns the function with HTTP expectations and resolves the failing test case.Target Branch