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

PixivHelper.sanitize_filename(): correctly cutting filename on linux #617

Merged
merged 1 commit into from
Jan 2, 2020

Conversation

split-n
Copy link
Contributor

@split-n split-n commented Jan 2, 2020

Cutting filename to <= 249 bytes in UTF8 on Linux environment.
For fixing #525

For Linux, 255 bytes is the maximum for filename (not full path).
And almost all Linux environments use UTF-8 for path encoding.
And the path is used later with suffix ".pixiv" (consume 6 bytes).
So 249 bytes is maybe a minimum.

save = open(filename + '.pixiv', 'wb+', 4096)

Windows/Mac isn't affected.

Cutting filename to <= 249 bytes in UTF8 on Linux environment.
For fixing Nandaka#525

For Linux, 255 bytes is the maximum for filename (not full path).
And almost all Linux environments use UTF-8 for path encoding.
And the path is used later with suffix ".pixiv" (consume 6 bytes).
So 249 bytes is maybe a minimum.
https://github.com/Nandaka/PixivUtil2/blob/dbb810716c4824724c03ce8e022a5b5d31f41800/PixivHelper.py#L590

Windows/Mac isn't affected.
@Nandaka Nandaka merged commit 90afdec into Nandaka:master Jan 2, 2020
35122 pushed a commit to 35122/PixivUtil2 that referenced this pull request Oct 30, 2020
…andaka#617)

Cutting filename to <= 249 bytes in UTF8 on Linux environment.
For fixing Nandaka#525

For Linux, 255 bytes is the maximum for filename (not full path).
And almost all Linux environments use UTF-8 for path encoding.
And the path is used later with suffix ".pixiv" (consume 6 bytes).
So 249 bytes is maybe a minimum.
https://github.com/Nandaka/PixivUtil2/blob/dbb810716c4824724c03ce8e022a5b5d31f41800/PixivHelper.py#L590

Windows/Mac isn't affected.
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