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

Improper handling with non-ascii characters in response.redirect() in Zope 4/Python 3 #435

Closed
zopyx opened this issue Dec 18, 2018 · 2 comments

Comments

@zopyx
Copy link
Member

commented Dec 18, 2018

Situation:

  • user enters the name of form which is send as parameter name:unicode to Plone 5.2/Python 3
  • the browser view receives the parameter as str and creates response.redirect to
    self.context.absolute() + '/view' + name. In my case this is /Plone2/s3/view/ä
  • the browser redirects to /Plone2/s3/view/%E4 and waitress throws this exception:
2018-12-18 11:37:44,424 ERROR [waitress:341][waitress] Exception when serving /Plone2/s3/view/ääää
Traceback (most recent call last):
  File "/home/ajung/src/xmldirector.connector/eggs/waitress-1.1.0-py3.7.egg/waitress/channel.py", line 338, in service
    task.service()
  File "/home/ajung/src/xmldirector.connector/eggs/waitress-1.1.0-py3.7.egg/waitress/task.py", line 169, in service
    self.execute()
  File "/home/ajung/src/xmldirector.connector/eggs/waitress-1.1.0-py3.7.egg/waitress/task.py", line 399, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/home/ajung/src/xmldirector.connector/eggs/Zope-4.0b7-py3.7.egg/ZPublisher/httpexceptions.py", line 30, in __call__
    return self.application(environ, start_response)
  File "/home/ajung/src/xmldirector.connector/eggs/Zope-4.0b7-py3.7.egg/ZPublisher/WSGIPublisher.py", line 251, in publish_module
    path_info = path_info.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 16: invalid continuation byte

My browser view can clearly deal with a request to /Plone2/s3/view/ä - however something is going here with the unicode <-> utf8 conversion - either as part of the generation of the redirection URL and/or with improper %e4 as part of the redirection URL.

@zopyx

This comment has been minimized.

Copy link
Member Author

commented Dec 18, 2018

I think that the redirect() call generates an improper redirection URL here:

The correct redirection URL for /Plone2/s3/view/ä must be /Plone2/s3/view/%C3%A4 but not /Plone2/s3/view/%E4.

@zopyx zopyx changed the title Dealing with non-ascii chars in (WSGI) publisher in Zope 4 Improper dealing with non-ascii characters in response.redirect() in Zope 4/Python 3 Dec 18, 2018

@zopyx zopyx added the bug label Dec 18, 2018

@icemac icemac added this to the 4.0 final milestone Dec 18, 2018

@icemac icemac added this to To do in Zope 4 final release via automation Dec 18, 2018

@zopyx zopyx changed the title Improper dealing with non-ascii characters in response.redirect() in Zope 4/Python 3 Improper handling with non-ascii characters in response.redirect() in Zope 4/Python 3 Dec 18, 2018

@dataflake

This comment has been minimized.

Copy link
Member

commented Feb 9, 2019

The redirect call does not seem to be the issue. It's how paths are handled in the WSGI publisher.

The combination of 6c15c71 by @sallner and 707df73 by @icemac ends up with a strange mixture. Under Python 3, it takes a unicode value, encodes it into latin1, and immediately decodes it using UTF-8. I think we can all agree that can't work.

What is the intent here?

@dataflake dataflake self-assigned this Apr 29, 2019

@dataflake dataflake closed this in ca445a6 Apr 29, 2019

Zope 4 final release automation moved this from To do to Done Apr 29, 2019

icemac added a commit that referenced this issue May 3, 2019

Do not quote `@` on redirect.
This is a regression introduced in #435.

dataflake added a commit that referenced this issue May 7, 2019

Do not quote `@` on redirect. (#586)
* Do not quote `@` on redirect.

This is a regression introduced in #435.

* - next attempt at a fix

* - missed a character

* - remove unused import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
4 participants
You can’t perform that action at this time.