8000 query string not escaping '+' · Issue #516 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

query string not escaping '+' #516

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

Closed
kurtbrose opened this issue Oct 29, 2019 · 10 comments
Closed

query string not escaping '+' #516

kurtbrose opened this issue Oct 29, 2019 · 10 comments
Labels

Comments

@kurtbrose
Copy link

1- create user with name='a+b'

2- fetch user with filter query set to name='a+b'; returns no items

3- fetch user with filter query set to name='a%2b'; returns user

I don't know how or where, but seems pretty clear somewhere it is doing ?name={name} in a query string, and it should be encoding but isn't

@kurtbrose
Copy link
Author

https://www.urlencoder.io/python/ -- recommended reading (-: should be an easy fix

@t8y8
Copy link
Collaborator
t8y8 commented Oct 31, 2019

We aren't doing encoding ourselves anywhere, it's handled by the http library we use.

I can take a look when I have time, but I'm not sure what options we have available to us over the lower layer's encoding

@kurtbrose
Copy link
Author

I fixed this by doing urlencode() on values before passing them to the API

@kurtbrose
Copy link
Author

dude, you are doing string munging to generate query params

def _append_view_filters(self, params):
for name, value in self.view_filters:
params.append('vf_{}={}'.format(name, value))

https://github.com/tableau/server-client-python/blob/master/tableauserverclient/server/request_options.py#L164

        self._append_view_filters(params)

        return "{0}?{1}".format(url, '&'.join(params))

@kurtbrose
Copy link
Author

sorry for being a little short, trying to get tableau integration working has been my life for the past week or so

@t8y8
Copy link
Collaborator
t8y8 commented Nov 1, 2019

Right, but our http library itself encodes those values when it makes the request (I had a bug in the opposite direction recently, maybe this is actually related to that)

We can look at encoding it at the places you just mentioned, I just want to make sure nothing gets double encoded

@kurtbrose
Copy link
Author

makes sense -- maybe it is possible to pass the query string to HTTP as a key/value dict instead of doing the string construction yourself?

@kurtbrose
Copy link
Author

that seems to be the recommended way to use requests: https://requests.kennethreitz.org/en/master/user/quickstart/#passing-parameters-in-urls

@kurtbrose
Copy link
Author
kurtbrose commented Nov 1, 2019

url = request_object.apply_query_params(url)
looking here the code manually smooshes up the URL, but instead could be parameters['params'] = request_object.get_query_params() or similar

there's no problem with different HTTP methods -- body data is data={...}; so even on a post request you can set params={...} and everything works fine

@jacalata
Copy link
Contributor

This works today.

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

4 participants
0