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

[bug] 502 Bad Gateway on entering a utf-8 string in URL field. #1995

Closed
karlcow opened this issue Jan 3, 2018 · 4 comments
Closed

[bug] 502 Bad Gateway on entering a utf-8 string in URL field. #1995

karlcow opened this issue Jan 3, 2018 · 4 comments

Comments

@karlcow
Copy link
Member

karlcow commented Jan 3, 2018

@softvision-oana-arbuzov found an interesting issue.

  1. Go to https://staging.webcompat.com/
  2. Enter "價格" in the URL field… and boom.

capture d ecran 2018-01-03 a 22 20 47

@karlcow
Copy link
Member Author

karlcow commented Jan 4, 2018

Additional tests.

  • é fails too. So anything which is not ascii.
  • http://愛.com/ fails too. (which is a problem, it should be converted to http://xn--vgu.com/) aka IDN
  • http://example.com/愛 works.

@karlcow
Copy link
Member Author

karlcow commented Jan 4, 2018

Ah! good. I was afraid it would be an issue with url parsing and libraries not handling idn, but it seems to be a lot simpler. We are sometimes a bit loose on strings. We should straighten that or switch to python 3.

http://™.com/
127.0.0.1 - - [04/Jan/2018 09:49:19] "POST /issues/new HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/karl/code/webcompat.com/webcompat/views.py", line 227, in create_issue
    response = report_issue(form, proxy=True).json()
  File "/Users/karl/code/webcompat.com/webcompat/issues.py", line 24, in report_issue
    data=json.dumps(build_formdata(form)))
  File "/Users/karl/code/webcompat.com/webcompat/form.py", line 231, in build_formdata
    summary = '{0} - {1}'.format(domain, problem_summary)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2122' in position 0: ordinal not in range(128)

@karlcow
Copy link
Member Author

karlcow commented Jan 4, 2018

# Do domain extraction for adding to the summary/title
url = form_object.get('url')
normalized_url = normalize_url(url)

form_object returns a unicode string

@karlcow
Copy link
Member Author

karlcow commented Jan 4, 2018

And just realized we extract twice the url

'url': form_object.get('url'),

karlcow added a commit to karlcow/webcompat.com that referenced this issue Jan 4, 2018
Make sure the URL is treated as a unicode string and that it doesn’t
break down the pipe when manipulating it.
karlcow added a commit to karlcow/webcompat.com that referenced this issue Jan 4, 2018
Fixing this because it is a secondary break uncovered in the 1995 issue.
karlcow added a commit to karlcow/webcompat.com that referenced this issue Jan 4, 2018
karlcow added a commit to karlcow/webcompat.com that referenced this issue Jan 4, 2018
@karlcow karlcow changed the title [bug] 502 Bad Gateway on entering a chinese string in URL field. [bug] 502 Bad Gateway on entering a utf-8 string in URL field. Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant