Skip to content

support file names that are not valid UTF-8#401

Open
curious-rabbit wants to merge 1 commit into
andreafrancia:masterfrom
curious-rabbit:utf
Open

support file names that are not valid UTF-8#401
curious-rabbit wants to merge 1 commit into
andreafrancia:masterfrom
curious-rabbit:utf

Conversation

@curious-rabbit

Copy link
Copy Markdown

trash-put crashed with UnicodeEncodeError on any file name that is not valid UTF-8. Such names are legal on Linux.

With this patch the Path value is percent-encoded from the raw bytes and decoded back the same way, so put, list, rm and restore keep the exact name. Output code escapes bytes that a stream can not take, so trash-list and trash-restore print such names instead of crashing.

@andreafrancia

Copy link
Copy Markdown
Owner

Good idea, thank you for the PR. I'll review this later because I've finished my time.

If you want check out if you followed the usual guidelines:

  • Please add behaviour explaining shell example. Maybe, if you want, add them as a feature description in markdown somewhere under docs/
  • The ensure that you used class based pytest tests.
  • Provide at least one test calling entire command (but from the inside) that uses Fakes.
  • Remove repetitions you see it.

@curious-rabbit

Copy link
Copy Markdown
Author
$ touch "$(printf 'bad\xffname')"
$ trash-put bad*name
Traceback (most recent call last):
  ...
UnicodeEncodeError: 'utf-8' codec can't encode byte 0xff in position 3

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

Successfully merging this pull request may close these issues.

2 participants