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

quoted urls UnicodeDecodeError #83

Open
laurentpayot opened this issue Aug 29, 2013 · 7 comments
Open

quoted urls UnicodeDecodeError #83

laurentpayot opened this issue Aug 29, 2013 · 7 comments

Comments

@laurentpayot
Copy link

I use quoted URLs such as /fr/livres/cr%C3%A9ation/ (for /fr/livres/création/).
get() is working fine with these urls but once I have the response if I try to use click() or submit() on it I get the following error:

/usr/lib/python3.3/http/cookiejar.py:1588: UserWarning: http.cookiejar bug!
Traceback (most recent call last):
  File "/usr/lib/python3.3/http/cookiejar.py", line 1586, in make_cookies
    parse_ns_headers(ns_hdrs), request)
  File "/usr/lib/python3.3/http/cookiejar.py", line 1543, in _cookies_from_attrs_set
    cookie = self._cookie_from_cookie_tuple(tup, request)
  File "/usr/lib/python3.3/http/cookiejar.py", line 1492, in _cookie_from_cookie_tuple
    req_host, erhn = eff_request_host(request)
  File "/usr/lib/python3.3/http/cookiejar.py", line 612, in eff_request_host
    erhn = req_host = request_host(request)
  File "/usr/lib/python3.3/http/cookiejar.py", line 597, in request_host
    url = request.get_full_url()
  File "/usr/local/lib/python3.3/dist-packages/WebTest-2.0.8.dev0-py3.3.egg/webtest/utils.py", line 116, in get_full_url
    return self._request.url
  File "/usr/local/lib/python3.3/dist-packages/WebOb-1.2.3-py3.3.egg/webob/request.py", line 505, in url
    url = self.path_url
  File "/usr/local/lib/python3.3/dist-packages/WebOb-1.2.3-py3.3.egg/webob/request.py", line 477, in path_url
    bpath_info = bytes_(self.path_info, self.url_encoding)
  File "/usr/local/lib/python3.3/dist-packages/WebOb-1.2.3-py3.3.egg/webob/descriptors.py", line 68, in fget
    return req.encget(key, encattr=encattr)
  File "/usr/local/lib/python3.3/dist-packages/WebOb-1.2.3-py3.3.egg/webob/request.py", line 167, in encget
    return bytes_(val, 'latin-1').decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 5: invalid continuation byte

  _warn_unhandled_exception()

I'm using Ubuntu 13.04 64 bit and Python 3.3.1 with the last commit of Webtest.

@gawel
Copy link
Member

gawel commented Apr 17, 2014

I think it's more a problem in WebOb / WSGI PEP. Every url should be latin1 encoded and the real url encoding is lost during the process (see hard coded latin-1 encoding in the traceback...).

Not sure that we'll be able to fix that one day...

@gawel
Copy link
Member

gawel commented Apr 17, 2014

Also, looks like it's related to #1

@NomadDemon
Copy link

i had this problem today
i had to "hack" webob to use UTF, to allow send
url = reverse('someurl', kwargs={'name': 'żółć'})
how about some hack/parameter for this? to allow UTF in urls?

@rjsparks
Copy link

rjsparks commented Jun 30, 2023

@gawel - bump?

We are going to pull WebTest out of one of our projects over this for now, which makes me sad.

This URL really should be useable through this test framework:
/community/personal/%C3%89ric%20Vyncke/manage/
But by the time it gets to
return bytes_(val, 'latin-1').decode(encoding) in webop.request.encget, the %C3%89 has been unescaped and val has an É in it.

@gawel
Copy link
Member

gawel commented Jul 2, 2023

@rjsparks as you noticed the "problem" is in webob, not webtest.

@rjsparks
Copy link

rjsparks commented Jul 4, 2023

Why the quotes around "problem"?

@bertjwregeer - I don't see a relevant issue at webob on a quick read. Are you already aware of this behavior?

@laurentpayot
Copy link
Author

I’m unsubscribing from this 10 years old thread because I moved from Python to JS/TS and Elm a loooong time ago. 🦕
I will let the repo owner close this issue when fixed… or not 😉

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

No branches or pull requests

4 participants