From e8cadd23d89c26a760220c67a381c1b857df99a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Thu, 13 Mar 2014 20:46:49 +0100 Subject: [PATCH] Fix a book reported by Mario. re #52 --- resources/php-epub-meta/epub.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/php-epub-meta/epub.php b/resources/php-epub-meta/epub.php index 60614ae..bbce683 100644 --- a/resources/php-epub-meta/epub.php +++ b/resources/php-epub-meta/epub.php @@ -205,7 +205,14 @@ class EPub { */ public function componentContentType($comp) { $comp = $this->decodeComponentName ($comp); - return $this->xpath->query("//opf:manifest/opf:item[@href='$comp']")->item(0)->getAttribute('media-type'); + $item = $this->xpath->query("//opf:manifest/opf:item[@href='$comp']")->item(0); + if ($item) return $item->getAttribute('media-type'); + + // I had at least one book containing %20 instead of spaces in the opf file + $comp = str_replace (" ", "%20", $comp); + $item = $this->xpath->query("//opf:manifest/opf:item[@href='$comp']")->item(0); + if ($item) return $item->getAttribute('media-type'); + return "application/octet-stream"; } private function getNavPointDetail ($node) {