[libgepub] Fixed epub:// SoupURI creation and concatenation



commit a2525fd55675247ff4b05383bb12dc3151889d3f
Author: Daniel GarcĂ­a Moreno <danigm wadobo com>
Date:   Wed Jul 12 11:18:18 2017 +0200

    Fixed epub:// SoupURI creation and concatenation
    
    We were using SoupURI to replace resource paths with custom scheme
    "epub", but we were using "epub://" for the root and that doesn't work
    correctly in SoupURI so the relative uri creation wasn't working.
    
    I've changed the "epub://" to "epub:///" and now the uri concatenation
    works.
    
    Before this patch:
    epub://text/ + ../image.jpeg -> epub://text/image.jpeg
    
    After this patch:
    epub:///text/ + ../image.jpeg -> epub:///image.jpeg

 libgepub/gepub-doc.c    |    2 +-
 libgepub/gepub-utils.c  |    4 ++--
 libgepub/gepub-widget.c |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/libgepub/gepub-doc.c b/libgepub/gepub-doc.c
index 0e595bd..5e73c71 100644
--- a/libgepub/gepub-doc.c
+++ b/libgepub/gepub-doc.c
@@ -496,7 +496,7 @@ gepub_doc_get_current (GepubDoc *doc)
  * @doc: a #GepubDoc
  *
  * Returns: (transfer full): the current chapter
- * data, with resource uris renamed so they have the epub:// prefix and all
+ * data, with resource uris renamed so they have the epub:/// prefix and all
  * are relative to the root file
  */
 GBytes *
diff --git a/libgepub/gepub-utils.c b/libgepub/gepub-utils.c
index 0a6e47e..3b9b9d1 100644
--- a/libgepub/gepub-utils.c
+++ b/libgepub/gepub-utils.c
@@ -27,7 +27,7 @@
 #include "gepub-text-chunk.h"
 
 
-/* Replaces the attr value with epub:// prefix for the tagname. This
+/* Replaces the attr value with epub:/// prefix for the tagname. This
  * function also makes the resource absolute based on the epub root
  */
 static void
@@ -37,7 +37,7 @@ set_epub_uri (xmlNode *node, const gchar *path, const gchar *tagname, const gcha
     xmlChar *text = NULL;
 
     SoupURI *baseURI;
-    gchar *basepath = g_strdup_printf ("epub://%s/", path);
+    gchar *basepath = g_strdup_printf ("epub:///%s/", path);
 
     baseURI = soup_uri_new (basepath);
     g_free (basepath);
diff --git a/libgepub/gepub-widget.c b/libgepub/gepub-widget.c
index f161945..a967e4b 100644
--- a/libgepub/gepub-widget.c
+++ b/libgepub/gepub-widget.c
@@ -238,8 +238,8 @@ resource_callback (WebKitURISchemeRequest *request, gpointer user_data)
       return;
 
     uri = g_strdup (webkit_uri_scheme_request_get_uri (request));
-    // removing "epub://"
-    path = uri + 7;
+    // removing "epub:///"
+    path = uri + 8;
     contents = gepub_doc_get_resource (widget->doc, path);
     mime = gepub_doc_get_resource_mime (widget->doc, path);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]