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

Improve decoding of mime-type in ZIP file #546

Merged
merged 1 commit into from Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core.js
Expand Up @@ -331,7 +331,7 @@ class FileTypeParser {
// - one entry indicating specific type of file.
// MS Office, OpenOffice and LibreOffice may put the parts in different order, so the check should not rely on it.
if (zipHeader.filename === 'mimetype' && zipHeader.compressedSize === zipHeader.uncompressedSize) {
const mimeType = await tokenizer.readToken(new Token.StringType(zipHeader.compressedSize, 'utf-8'));
const mimeType = (await tokenizer.readToken(new Token.StringType(zipHeader.compressedSize, 'utf-8'))).trim();

switch (mimeType) {
case 'application/epub+zip':
Expand Down
Binary file added fixture/fixture-crlf.epub
Binary file not shown.
4 changes: 4 additions & 0 deletions test.js
Expand Up @@ -46,6 +46,10 @@ const names = {
dng: [
'fixture-Leica-M10',
],
epub: [
'fixture',
'fixture-crlf',
],
nef: [
'fixture',
'fixture2',
Expand Down