Skip to content

Commit

Permalink
Improve decoding of mime-type in ZIP file (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit authored Jun 1, 2022
1 parent cffcf1f commit 1b10a71
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const names = {
dng: [
'fixture-Leica-M10',
],
epub: [
'fixture',
'fixture-crlf',
],
nef: [
'fixture',
'fixture2',
Expand Down

0 comments on commit 1b10a71

Please sign in to comment.