From c1733a39fd71cc3e39175dc3725ff3fc4ec2c46c Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Thu, 19 Jul 2018 00:09:54 +0200 Subject: [PATCH] Fixed image loading on certain ebooks --- .../BookHtmlContent.cs | 2 +- .../EpubReader/Readers/ChapterReader.cs | 34 ------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/BookHtmlContent.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/BookHtmlContent.cs index 4972f5f..ecdf1aa 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/BookHtmlContent.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/BookHtmlContent.cs @@ -85,7 +85,7 @@ namespace QuickLook.Plugin.EpubViewer basePath = System.IO.Path.GetDirectoryName(basePath); } string fullPath = String.Concat(basePath.Replace('\\', '/'), '/', relativePath); - return fullPath.Length > 1 ? fullPath.Substring(1) : String.Empty; + return fullPath.StartsWith("/") ? fullPath.Length > 1 ? fullPath.Substring(1) : String.Empty : fullPath; } private static async void OnChapterRefChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ChapterReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ChapterReader.cs index 32c2760..f6a44ab 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ChapterReader.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ChapterReader.cs @@ -10,7 +10,6 @@ namespace VersOne.Epub.Internal { public static List GetChapters(EpubBookRef bookRef) { - // return GetChapters(bookRef, bookRef.Schema.Navigation.NavMap); return GetChapters(bookRef, bookRef.Schema.Package.Spine, bookRef.Schema.Navigation.NavMap); } @@ -46,38 +45,5 @@ namespace VersOne.Epub.Internal } return result; } - - public static List GetChapters(EpubBookRef bookRef, List navigationPoints, EpubChapterRef parentChapter = null) - { - List result = new List(); - foreach (EpubNavigationPoint navigationPoint in navigationPoints) - { - string contentFileName; - string anchor; - int contentSourceAnchorCharIndex = navigationPoint.Content.Source.IndexOf('#'); - if (contentSourceAnchorCharIndex == -1) - { - contentFileName = WebUtility.UrlDecode(navigationPoint.Content.Source); - anchor = null; - } - else - { - contentFileName = WebUtility.UrlDecode(navigationPoint.Content.Source.Substring(0, contentSourceAnchorCharIndex)); - anchor = navigationPoint.Content.Source.Substring(contentSourceAnchorCharIndex + 1); - } - if (!bookRef.Content.Html.TryGetValue(contentFileName, out EpubTextContentFileRef htmlContentFileRef)) - { - throw new Exception(String.Format("Incorrect EPUB manifest: item with href = \"{0}\" is missing.", contentFileName)); - } - EpubChapterRef chapterRef = new EpubChapterRef(htmlContentFileRef); - chapterRef.ContentFileName = contentFileName; - chapterRef.Anchor = anchor; - chapterRef.Parent = parentChapter; - chapterRef.Title = navigationPoint.NavigationLabels.First().Text; - chapterRef.SubChapters = GetChapters(bookRef, navigationPoint.ChildNavigationPoints, chapterRef); - result.Add(chapterRef); - } - return result; - } } }