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

Parsing request bodies containing file uploads with a filename containing two single quotes fails #1177

Closed
ThiefMaster opened this issue Sep 21, 2017 · 1 comment · Fixed by #1208
Labels

Comments

@ThiefMaster
Copy link
Member

I can reproduce this in Flask but I'm pretty sure this is a bug in Werkzeug.

In [6]: app = Flask(__name__)
   ...: @app.route('/upload', methods=('POST',))
   ...: def upload():
   ...:     print request.form
   ...:     print request.files
   ...:     return 'blah'
   ...: app.run(port=31337)
http -f post http://127.0.0.1:31337/upload "file@/tmp/t'es't.txt"
Traceback (most recent call last):
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "<ipython-input-6-c04743f50a59>", line 4, in upload
    print request.form
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/utils.py", line 73, in __get__
    value = self.func(obj)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/wrappers.py", line 523, in form
    self._load_form_data()
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/flask/wrappers.py", line 185, in _load_form_data
    RequestBase._load_form_data(self)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/wrappers.py", line 371, in _load_form_data
    mimetype, content_length, options)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/formparser.py", line 195, in parse
    content_length, options)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/formparser.py", line 100, in wrapper
    return f(self, stream, *args, **kwargs)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/formparser.py", line 212, in _parse_multipart
    form, files = parser.parse(stream, boundary, content_length)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/formparser.py", line 519, in parse
    return self.cls(form), self.cls(files)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/datastructures.py", line 406, in __init__
    for key, value in mapping or ():
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/formparser.py", line 517, in <genexpr>
    form = (p[1] for p in formstream if p[0] == 'form')
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/formparser.py", line 476, in parse_parts
    for ellt, ell in self.parse_lines(file, boundary, content_length):
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/formparser.py", line 403, in parse_lines
    disposition, extra = parse_options_header(disposition)
  File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/werkzeug/http.py", line 368, in parse_options_header
    option_value = _unquote(option_value).decode(encoding)
LookupError: unknown encoding: "t

Installed versions: Flask==0.12.2, Werkzeug==0.12.2

@ThiefMaster
Copy link
Member Author

#1091 sounds related.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant