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

Cannot perform a request with url containing braces #102

Closed
Martoon-00 opened this issue Aug 20, 2020 · 7 comments
Closed

Cannot perform a request with url containing braces #102

Martoon-00 opened this issue Aug 20, 2020 · 7 comments
Labels

Comments

@Martoon-00
Copy link

With the recent updates, the only way to construct a Url value from a string known at runtime is via URI type.

However, I have a case that got broken with this update. For instance, if I have the following link:
https://gitlab.com/morley-framework/morley/-/issues/new?issue[title]=Indigo%20website:%20

it fails to parse as URI because it contains [ and ] in query parameters which are not allowed there. Nevertheless, this string is considered a valid URL by browsers and by the old version of req, and using such format with braces for query parameter name seems to be quite wide-spread.

This issue indeed seems weird because normally URLs form a subset of URIs, but apparently, in practice that does not hold.
Would like to hear your opinion on which is the best way to deal with this.

@mrkkrp
Copy link
Owner

mrkkrp commented Aug 20, 2020

My browser converts your link into this:

https://gitlab.com/morley-framework/morley/-/issues/new?issue%5Btitle%5D=Indigo%20website:%20

That link is valid and is accepted by modern-uri:

*Text.URI> mkURI "https://gitlab.com/morley-framework/morley/-/issues/new?issue%5Btitle%5D=Indigo%20website:%20"
URI {uriScheme = Just "https", uriAuthority = Right (Authority {authUserInfo = Nothing, authHost = "gitlab.com", authPort = Nothing}), uriPath = Just (False,"morley-framework" :| ["morley","-","issues","new"]), uriQuery = [QueryParam "issue[title]" "Indigo website: "], uriFragment = Nothing}

@mrkkrp
Copy link
Owner

mrkkrp commented Aug 22, 2020

@Martoon-00 Should we close or you still want some sort of change?

@Martoon-00
Copy link
Author

Could you tell which browser do you use? Because when I try firefox and chrome, they don't seem to display any escaping.

@mrkkrp
Copy link
Owner

mrkkrp commented Aug 25, 2020

I use Google Chrome.

@Martoon-00
Copy link
Author

Martoon-00 commented Sep 1, 2020

I asked several people, and they don't have such conversion performed automatically, at least in the address bar (this includes tries with Firefox and Google Chrome; with Linux and Mac as OS). Though if I press "Copy Link Location" in firefox, it escapes.

Despite this feature helps the user to avoid the issue, it does not seem reliable to me.

@mrkkrp
Copy link
Owner

mrkkrp commented Sep 2, 2020

It is not about the feature, which is just a courtesy performed by browsers sometimes. It is about the fact that square brackets should be escaped in URIs.

@Martoon-00
Copy link
Author

Ah yes, I see, even browsers have it escaped inside and naturally operate only with valid URIs.

Okay, then putting the responsibility to escape urls on users seems justified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants