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

Option to disable UTF-8 encoding for Content-Disposition for KOBO? #294

Closed
mikespub opened this issue Dec 28, 2023 · 6 comments
Closed

Option to disable UTF-8 encoding for Content-Disposition for KOBO? #294

mikespub opened this issue Dec 28, 2023 · 6 comments

Comments

@mikespub
Copy link

Description

I've taken over maintenance of COPS and switched new releases to use ZipStream when updating metadata of EPUB books on the fly before downloading them. Overall this worked very well - thanks :-)

We're dealing with quite a range of e-book readers as clients here, all of which have their own issues and limitations with regards to browsers. Now one of them has bit us again:

apparently KOBO e-readers can't deal with UTF-8 encoded filenames for Content-Disposition - see mikespub-org/seblucas-cops#71

From what @tobybryans tested changing this line in sendHttpHeaders()

$disposition .= "; filename*=UTF-8''{$urlencoded}";

to use plain quotes instead of UTF-8 worked well in his case:

#            $disposition .= "; filename*=UTF-8''{$urlencoded}";
            $disposition .= "; filename=\"{$safeOutput}\"";

Is there any way this could be made configurable in ZipStream?

Thanks

@maennchen
Copy link
Owner

@mikespub You should be able to set the header yourself if you set sendHttpHeaders: false

@mikespub
Copy link
Author

Yes, that was the other option I had in mind - but it never hurts to ask, right? :-)

@maennchen
Copy link
Owner

@mikespub No, of course not 😊

I‘m currently thinking that is is probably niche enough to not warrant a dedicated option.

@mikespub
Copy link
Author

Fair enough - closing the issue here then.

@mikespub mikespub closed this as not planned Won't fix, can't repro, duplicate, stale Dec 28, 2023
@maennchen
Copy link
Owner

@mikespub I was thinking about this a bit more. I think there should be a simple way to implement this which doesn’t require a new config parameter:

Use mb_detect_encoding to detect if the filename is ASCII only and only set UTF-8 if it is not.

I‘d be open for a PR if you would want to give this a try.

@mikespub
Copy link
Author

mikespub commented Jan 2, 2024

I appreciate this, but please note that according to http://test.greenbytes.de/tech/tc2231/ it's not only plain ASCII but also plain ISO-8859-1 that should be supported without UTF-8 encoding.

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

No branches or pull requests

2 participants