Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing URI with HttpUri.from(String uri) throws "IllegalArgumentException: Bad authority" when path is empty #12404

Closed
2 tasks
jomapp opened this issue Oct 18, 2024 · 2 comments · Fixed by #12425
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@jomapp
Copy link

jomapp commented Oct 18, 2024

Jetty version(s)
12.0.14

Jetty Environment
core

Java version/vendor (use: java -version)
21.0.2+13-LTS

OS type/version
Ubuntu 22.04

Description

Parsing an URI with HttpUri.from(String uri) throws an "IllegalArgumentException: Bad authority", when the path is empty (path-empty), but a query is present in the URI. E.g. "http://example.com?id=123". According to https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 an empty path followed by a query section is valid though.

Thanks for looking into this issue!

How to reproduce?

  • Run HttpURI.from("http://example.com?id=123")
  • See error
@jomapp jomapp added the Bug For general bugs on Jetty side label Oct 18, 2024
@joakime
Copy link
Contributor

joakime commented Oct 18, 2024

Noting that standard java URI supports this.

|  Welcome to JShell -- Version 17.0.11
|  For an introduction type: /help intro

jshell> var uri = new URI("http://example.com?id=123")
uri ==> http://example.com?id=123

jshell> uri.getPath()
$2 ==> ""

jshell> uri.getQuery()
$3 ==> "id=123"

jshell> uri.getAuthority()
$4 ==> "example.com"

gregw added a commit that referenced this issue Oct 24, 2024
Fix #12404 by accepting empty paths in HttpURI
@gregw
Copy link
Contributor

gregw commented Oct 24, 2024

@jomapp can you review #12425

gregw added a commit that referenced this issue Oct 24, 2024
Fix #12404 by accepting empty paths in HttpURI
@gregw gregw closed this as completed in cccfd20 Oct 29, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.15 FROZEN Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants