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

Sydent returns a 500 error when email address or other email fields contain non-ascii characters #188

Closed
ara4n opened this issue Aug 12, 2019 · 4 comments

Comments

@ara4n
Copy link
Member

ara4n commented Aug 12, 2019

Traceback (most recent call last):
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/http.py", line 1705, in dataReceived
    finishCallback(data[contentLength:])
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/http.py", line 2121, in _finishRequestBody
    self.allContentReceived()
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/http.py", line 2196, in allContentReceived
    req.requestReceived(command, path, version)
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/http.py", line 920, in requestReceived
    self.process()
--- <exception caught here> ---
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/server.py", line 199, in process
    self.render(resrc)
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/server.py", line 259, in render
    body = resrc.render(self)
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/resource.py", line 250, in render
    return m(request)
  File "sydent/http/servlets/store_invite_servlet.py", line 104, in render_POST
    sendEmail(self.sydent, "email.invite_template", address, substitutions)
  File "sydent/util/emailutils.py", line 54, in sendEmail
    allSubstitutions[k] = v.decode('utf8')
  File "/home/vectoris/venv/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 1: ordinal not in range(128)


Traceback (most recent call last):
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/http.py", line 1705, in dataReceived
    finishCallback(data[contentLength:])
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/http.py", line 2121, in _finishRequestBody
    self.allContentReceived()
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/http.py", line 2196, in allContentReceived
    req.requestReceived(command, path, version)
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/http.py", line 920, in requestReceived
    self.process()
--- <exception caught here> ---
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/server.py", line 199, in process
    self.render(resrc)
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/server.py", line 259, in render
    body = resrc.render(self)
  File "/home/vectoris/venv/local/lib/python2.7/site-packages/twisted/web/resource.py", line 250, in render
    return m(request)
  File "sydent/http/servlets/store_invite_servlet.py", line 104, in render_POST
    sendEmail(self.sydent, "email.invite_template", address, substitutions)
  File "sydent/util/emailutils.py", line 67, in sendEmail
    raise EmailAddressException()
sydent.util.emailutils.EmailAddressException:
@anoadragon453
Copy link
Member

I wonder if switching to python3 would solve these unicode issues?

@richvdh
Copy link
Member

richvdh commented Jan 15, 2020

as of 687d774 (#198), it now returns a 500 rather than hanging, which is a minor improvement I guess.

@richvdh richvdh changed the title Sydent can hang with utf8 encoding error Sydent returns a 500 error when email address or other email fields contain non-ascii characters Jan 15, 2020
@richvdh
Copy link
Member

richvdh commented Jan 15, 2020

I wonder if switching to python3 would solve these unicode issues?

If we do it right, yes, it would probably get fixed as a side-effect of doing so.
https://github.com/matrix-org/sydent/pull/239/files#diff-2aea5cf83e41d5063d3c49a8c859b992R60 looks like it is sorting out the line causing the first exception here.

@DMRobertson
Copy link
Contributor

This symptom is still visible today, see #458. That issue also has an encoding problem, but it comes later (from within smtplib). I'll close this in favour of #458.

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