[devhelp] link: don't escape the anchor
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] link: don't escape the anchor
- Date: Tue, 21 May 2013 11:31:35 +0000 (UTC)
commit 3d0c0fc2ff90631761898392f5fc35690e94fb56
Author: Aleksander Morgado <aleksander lanedo com>
Date: Tue May 21 13:29:02 2013 +0200
link: don't escape the anchor
The previous commit broke searching, as g_filename_to_uri() actually escapes the
anchor symbol used to specify sections within a file. Fix the issue by keeping
the anchor before building the URI with g_filename_to_uri(), and append it
afterwards.
src/dh-link.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/dh-link.c b/src/dh-link.c
index f503471..3a4ece6 100644
--- a/src/dh-link.c
+++ b/src/dh-link.c
@@ -227,7 +227,7 @@ dh_link_get_book_id (DhLink *link)
gchar *
dh_link_get_uri (DhLink *link)
{
- gchar *base, *filename, *uri;
+ gchar *base, *filename, *uri, *anchor;
if (link->type == DH_LINK_TYPE_BOOK)
base = link->base;
@@ -235,7 +235,22 @@ dh_link_get_uri (DhLink *link)
base = link->book->base;
filename = g_build_filename (base, link->filename, NULL);
+
+ anchor = strrchr (filename, '#');
+ if (anchor) {
+ *anchor = '\0';
+ anchor++;
+ }
+
uri = g_filename_to_uri (filename, NULL, NULL);
+
+ if (anchor) {
+ gchar *uri_with_anchor;
+
+ uri_with_anchor = g_strconcat (uri, "#", anchor, NULL);
+ g_free (uri);
+ uri = uri_with_anchor;
+ }
g_free (filename);
return uri;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]