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

Issue with + in filename #45

Closed
t20100 opened this issue Jun 30, 2021 · 4 comments · Fixed by silx-kit/h5web#774
Closed

Issue with + in filename #45

t20100 opened this issue Jun 30, 2021 · 4 comments · Fixed by silx-kit/h5web#774
Assignees

Comments

@t20100
Copy link
Member

t20100 commented Jun 30, 2021

Running H5Web("new_file+d.h5") from a notebook leads to opening "new_file d.h5" on the server side (its already changed in the GET request).

Logs on the server side:

    Traceback (most recent call last):
      File "lib/python3.8/site-packages/tornado/web.py", line 1702, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "lib/python3.8/site-packages/tornado/web.py", line 3173, in wrapper
        return method(self, *args, **kwargs)
      File "lib/python3.8/site-packages/jupyterlab_h5web/handlers.py", line 25, in get
        with h5py.File(as_absolute_path(self.base_dir, Path(file_path)), "r") as h5file:
      File "lib/python3.8/site-packages/h5py/_hl/files.py", line 424, in __init__
        fid = make_fid(name, mode, userblock_size,
      File "lib/python3.8/site-packages/h5py/_hl/files.py", line 190, in make_fid
        fid = h5f.open(name, flags, fapl=fapl)
      File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
      File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
      File "h5py/h5f.pyx", line 96, in h5py.h5f.open
    OSError: Unable to open file (unable to open file: name = '/home/new_file d.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
@t20100
Copy link
Member Author

t20100 commented Jul 1, 2021

Probably need to use quote_plus

@t20100
Copy link
Member Author

t20100 commented Jul 1, 2021

Issue is also when opening h5web with a double click from the file browser.

@loichuder
Copy link
Member

loichuder commented Aug 5, 2021

After thorough investigation, the escaping happens when the request URL is parsed on the backend. The culprit is tornado's parse_qs_bytes that parses arguments expecting them to be URL-encoded.

>>> parse_qs_bytes('file=stack+.h5&path=/')
{'file': [b'stack .h5'], 'path': [b'/']}
>>> parse_qs_bytes('file=stack%2B.h5&path=%2F')
{'file': [b'stack+.h5'], 'path': [b'/']}

To avoid problems of this type in the future, we should ensure that the filename is encoded every time it roundtrips between the front-end and the back-end.

This means encoding should happen in the following situations:

@loichuder
Copy link
Member

Fixed by silx-kit/h5web#774 and silx-kit/h5web#781

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