modern-uri icon indicating copy to clipboard operation
modern-uri copied to clipboard

Colons in path are escaped

Open BrechtSerckx opened this issue 1 year ago • 1 comments

Version: modern-uri-0.3.4.4 (also occurs on older)

Colons in path pieces are percent-encoded, while it seems to me from https://www.rfc-editor.org/rfc/rfc3986#section-3.3 that they can appear unencoded from the second path piece on.

[nix-shell:~/]$ ghci
GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help
ghci> import Data.Text
ghci> import Text.URI
ghci> Right u = mkURI (pack "https://mybusinessbusinessinformation.googleapis.com/v1/categories:batchGet")
ghci> render u
"https://mybusinessbusinessinformation.googleapis.com/v1/categories%3abatchGet"

This gives issues with f.e. Google, which uses colons in paths but does not accept the percent-encoded variant.

BrechtSerckx avatar Oct 03 '22 13:10 BrechtSerckx

RFC 3986 is quite dense. It looks like unless a URI is a "Relative Reference" (basically it is something without a scheme), then : is allowed in path segments. Otherwise it is forbidden in the very first segment, which makes sense because in that case the prefix (everything before :) could start looking like a scheme :thinking:

Frankly, I think it is admissible to just allow : to be unescaped. I may get to doing it myself, but you are welcome to open a PR if you want to speed things up.

mrkkrp avatar Oct 04 '22 19:10 mrkkrp

This should be fixed now. 0.3.6.0 is on Hackage.

mrkkrp avatar Oct 27 '22 19:10 mrkkrp