Skip to content

Commit 1b10a71

Browse files
authored
Improve decoding of mime-type in ZIP file (#546)
1 parent cffcf1f commit 1b10a71

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class FileTypeParser {
331331
// - one entry indicating specific type of file.
332332
// MS Office, OpenOffice and LibreOffice may put the parts in different order, so the check should not rely on it.
333333
if (zipHeader.filename === 'mimetype' && zipHeader.compressedSize === zipHeader.uncompressedSize) {
334-
const mimeType = await tokenizer.readToken(new Token.StringType(zipHeader.compressedSize, 'utf-8'));
334+
const mimeType = (await tokenizer.readToken(new Token.StringType(zipHeader.compressedSize, 'utf-8'))).trim();
335335

336336
switch (mimeType) {
337337
case 'application/epub+zip':

fixture/fixture-crlf.epub

718 KB
Binary file not shown.

test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ const names = {
4646
dng: [
4747
'fixture-Leica-M10',
4848
],
49+
epub: [
50+
'fixture',
51+
'fixture-crlf',
52+
],
4953
nef: [
5054
'fixture',
5155
'fixture2',

0 commit comments

Comments
 (0)