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

Cannot create a task with 👀 character in the uploaded filename #6528

Closed
2 tasks
azhavoro opened this issue Jul 20, 2023 · 5 comments
Closed
2 tasks

Cannot create a task with 👀 character in the uploaded filename #6528

azhavoro opened this issue Jul 20, 2023 · 5 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@azhavoro
Copy link
Contributor

My actions before raising this issue

Steps to Reproduce (for bugs)

Expected Behaviour

Current Behaviour

Possible Solution

Context

Your Environment

  • Git hash commit (git log -1):
  • Docker version docker version (e.g. Docker 17.0.05):
  • Are you using Docker Swarm or Kubernetes?
  • Operating System and version (e.g. Linux, Windows, MacOS):
  • Code example or link to GitHub repo or gist to reproduce problem:
  • Other diagnostic information / logs:
    Logs from `cvat` container
@azhavoro azhavoro added the bug Something isn't working label Jul 20, 2023
@bsekachev bsekachev added the good first issue Good for newcomers label Mar 11, 2024
@AndrewLuGit
Copy link
Contributor

I would like to be assigned this issue

@AndrewLuGit
Copy link
Contributor

The cause of this issue seems to be because of this line in views.py: https://github.com/opencv/cvat/blob/f22322f4349a91bbb645dfcacf1e799d870a6f16/cvat/apps/engine/views.py#L984

When there are characters that are not encodable in latin-1 such as 👀 in the file name, in the response header the file name gets encoded using MIME encoding, and so retrieving the file name from the response header can lead to unexpected results. My proposed solution is to simply decode the file name in the _maybe_append_upload_info_entry method, like so:

def _maybe_append_upload_info_entry(self, filename: str):
    task_data = cast(Data, self._object.data)

    raw, encoding = decode_header(filename)[0]

    if encoding is not None:
        filename = raw.decode(encoding)

    filename = self._prepare_upload_info_entry(filename)
    task_data.client_files.get_or_create(file=filename)

@AndrewLuGit
Copy link
Contributor

@nmanovic am I good to create a PR for this?

@nmanovic
Copy link
Contributor

@AndrewLuGit , please do.

azhavoro added a commit that referenced this issue Apr 4, 2024
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->
This fixes issue #6528, as filenames with special characters must be
decoded from the MIME header back into UTF-8.

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [x] I have created a changelog fragment <!-- see top comment in
CHANGELOG.md -->
- [ ] I have updated the documentation accordingly
- [x] I have added tests to cover my changes
- [x] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [x] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.

---------

Co-authored-by: Andrey Zhavoronkov <[email protected]>
@azhavoro
Copy link
Contributor Author

azhavoro commented Apr 8, 2024

Fixed in #7646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Development

No branches or pull requests

4 participants