-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[API] Encode URI before doing URL substitutions #2394
Comments
The URL is encoded during the Try going to the search component page, for example, and typing in the prompt |
Try this out with the @ symbol, it doesn't get encoded to %40 which causes 502 bad gateway errors for some results on your link. Also worth trying out with /, which doesn't get encoded either. |
Searching for |
I see that now, but it's still not getting escaped. Try with % and it'll return a 400 Bad Request. Point is you should be consistently seeing escaped characters like %40 and %25. I can't manually work around this either with encodeURIComponent() because {query} doesn't seem to get interpolated when I do this:
|
You would have to do as apiSettings: {
url: '/users/autocomplete/email/{query}',
urlVariables: {
query: encodeURIComponent(query)
})
} I can see both sides here. My fear is double encoding which becomes an issue when blackboxed JS code (like this API module) happens to modify your strings when they are passed along to the server. I guess the argument for is I'll muddle this over. |
For anyone else who comes across this, it is fairly easy to fix on the calling end with:
If it is encoding some special characters like mentioned above, it may cause other issues for some people. But I'm guessing the vast majority just care about ?, +, etc being encoded so this should work for them. |
I'll be revisiting this shortly in |
Added in Keep in mind if you were encoding in |
Added |
I'm trying to connect to a remote API that requires a query string with characters that need to be properly URI-encoded. I discovered that Semantic UI's API behavior module currently doesn't URI encode the
url
settings at all, which is a bit of an issue, because I can't encode the query string myself since I need to use a URL substitution to capture the user's query (if I do, it'll try to encode the curly brackets from{query}
, which will cause URL substitution to be skipped. Would it be possible to URI encode theurl
before performing the substitutions?(I'm on the
next
branch)The text was updated successfully, but these errors were encountered: