Skip to content

query string not escaping '+' #516

Closed

Description

@kurtbrose

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

Activity

  1. kurtbrose commented on Oct 29, 2019

    @kurtbrose
    Author

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

  2. t8y8 commented on Oct 31, 2019

    @t8y8
    Contributor

    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

  3. kurtbrose commented on Oct 31, 2019

    @kurtbrose
    Author

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

  4. kurtbrose commented on Oct 31, 2019

    @kurtbrose
    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))
  5. kurtbrose commented on Oct 31, 2019

    @kurtbrose
    Author

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

  6. t8y8 commented on Nov 1, 2019

    @t8y8
    Contributor

    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

  7. kurtbrose commented on Nov 1, 2019

    @kurtbrose
    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?

  8. kurtbrose commented on Nov 1, 2019

    @kurtbrose
    Author
  9. kurtbrose commented on Nov 1, 2019

    @kurtbrose
    Author

    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

  10. jacalata commented on Feb 16, 2023

    @jacalata
    Contributor

    This works today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions