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

Uri: inconsistent query param names (url-encode) when .renderString-ing #7127

Open
yurique opened this issue May 28, 2023 · 3 comments
Open
Labels
uri raze it and salt the earth whence it grew

Comments

@yurique
Copy link
Contributor

yurique commented May 28, 2023

Uri seems to behave differently depending on where it "comes" from. Here's an example:

scala> import org.http4s._
import org.http4s._

scala> val uri = Uri.fromString("https://site.nowhere/?with:colon=abc").toOption.get
val uri: org.http4s.Uri = https://site.nowhere/?with:colon=abc

scala> val copy = uri.copy(query = Query.empty).setQueryParams(uri.multiParams)
val copy: org.http4s.Uri = https://site.nowhere/?with%3Acolon=abc

scala> uri.renderString
val res0: String = https://site.nowhere/?with:colon=abc

scala> copy.renderString
val res1: String = https://site.nowhere/?with%3Acolon=abc

scala> uri.query.params
val res2: Map[String,String] = Map(with:colon -> abc)

scala> copy.query.params
val res3: Map[String,String] = Map(with:colon -> abc)

scala> uri == copy
val res4: Boolean = true

scala> uri.query == copy.query
val res5: Boolean = true

scala> uri.renderString == copy.renderString
val res6: Boolean = false

scala> uri.query == copy.query
val res7: Boolean = true

scala> uri.query.renderString == copy.query.renderString
val res8: Boolean = false

The biggest thing here is that two equal (==) queries produce different results with .renderString.

Another thing I'd argue - the colon (:) should not be url-encoded in this case (at least my quick googling of it suggests so). There might be other character not covered by org.http4s.internal.UriCoding#QueryNoEncode that should also not be url-encoded.

@yurique yurique changed the title Uri: inconsistent query param names (url-encode) Uri: inconsistent query param names (url-encode) when .renderString-ing May 28, 2023
@armanbilge armanbilge added the uri raze it and salt the earth whence it grew label May 28, 2023
@tothpeti
Copy link

I am new to OSS contributing, but I would like to work on this issue.

@armanbilge
Copy link
Member

@tothpeti welcome, thank you! feel free to ask any questions here or on Discord and I encourage you to put up a draft PR very very early (e.g. just start by adding some failing tests) so everyone can follow along your progress and help where we can :)

tothpeti added a commit to tothpeti/http4s that referenced this issue Aug 17, 2023
tothpeti added a commit to tothpeti/http4s that referenced this issue Aug 17, 2023
tothpeti added a commit to tothpeti/http4s that referenced this issue Aug 19, 2023
tothpeti added a commit to tothpeti/http4s that referenced this issue Aug 21, 2023
tothpeti added a commit to tothpeti/http4s that referenced this issue Aug 21, 2023
@tothpeti
Copy link

Unfortunately, I haven't been able to make any noticable progression with the ticket since I picked it up. This is why I will unassign myself from it.

@tothpeti tothpeti removed their assignment Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
uri raze it and salt the earth whence it grew
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants