From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Jan_B=F6cker?= Subject: Re: Re: org-protocol: non-ASCII characters Date: Sat, 13 Feb 2010 14:22:25 +0100 Message-ID: <4B76A791.1090808@jboecker.de> References: <86tyu2d5xw.fsf@mn.cs.uvic.ca> <4B693FBD.9010608@jboecker.de> <86d40k9702.fsf_-_@mn.cs.uvic.ca> <4B6D73A2.8000403@jboecker.de> <4B6D7E1A.3030807@jboecker.de> <878wb4rmm6.fsf@gmx.de> <16e9be801002121423y5bdff5bdy2e9e7503f8deb154@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000802010307040008080603" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NgHxH-000559-1h for emacs-orgmode@gnu.org; Sat, 13 Feb 2010 08:22:39 -0500 Received: from [140.186.70.92] (port=54708 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NgHxF-000551-4b for emacs-orgmode@gnu.org; Sat, 13 Feb 2010 08:22:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NgHxD-000338-CQ for emacs-orgmode@gnu.org; Sat, 13 Feb 2010 08:22:36 -0500 Received: from mail7.worldserver.net ([217.13.200.27]:59812) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NgHxD-00032w-0M for emacs-orgmode@gnu.org; Sat, 13 Feb 2010 08:22:35 -0500 In-Reply-To: <16e9be801002121423y5bdff5bdy2e9e7503f8deb154@mail.gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: dmg Cc: emacs-orgmode This is a multi-part message in MIME format. --------------000802010307040008080603 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit On 12.02.2010 23:23, dmg wrote: > For evince, I think I have found a problem in the parsing of the link. > Evince already encodes > the URL, but it does not encode the '/', hence you will get a link like this: > > emacsclient 'org-protocol://remember://docview/tmp/00%C3%A1%C3%A9%C3%AD%C3%B3%C3%BA.pdf::1' > > the filename is /tmp/00αινσϊ.pdf > > But emacs incorrectly stops parsing the link after tmp/ I think I have found the proper way to handle this in evince. Check out the attached patch or pull from: git://github.com/jboecker/evince.git This code first retrieves the non-URI-encoded UTF-8 filename and passes that to uri_encode. Should g_file_get_path return NULL, we abort, because the URI specifies something in gnomes VFS layer that has no local path, so the link would not work, anyway. > By the way, xournal now supports store-link Works as advertised, thanks! The only problem I have left now is a cosmetic one: when I store a link to, say, /tmp/test.xoj, in Org it becomes file://tmp/test.xoj instead of file:/tmp/test.xoj. (I have patched xournal and evince to generate file: instead of docview: links.) This is because org-protocol-sanitize-uri is called after decoding the string, allegedly because emacsclient compresses multiple slashes in a row to one. However, it seems that this function should be applied /before/ the string is URL-decoded. Is this a bug? --------------000802010307040008080603 Content-Type: text/plain; name="0001-bugfix-in-encode_uri-cast-to-unsigned-char-to-get-th.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-bugfix-in-encode_uri-cast-to-unsigned-char-to-get-th.pa"; filename*1="tch" >From f777bca64fd23066f626bc55cee6a81d6e03dac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6cker?= Date: Sat, 13 Feb 2010 12:38:39 +0100 Subject: [PATCH 1/2] bugfix in encode_uri: cast to unsigned char to get the correct byte value --- libview/ev-view.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libview/ev-view.c b/libview/ev-view.c index c334fdc..1130d39 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -5775,8 +5775,8 @@ static void encode_uri(gchar *encoded_uri, gint bufsize, const gchar *uri) if (k + 4 >= bufsize) break; encoded_uri[k++] = '%'; - encoded_uri[k++] = hexa[uri[i] / 16]; - encoded_uri[k++] = hexa[uri[i] % 16]; + encoded_uri[k++] = hexa[(unsigned char)uri[i] / 16]; + encoded_uri[k++] = hexa[(unsigned char)uri[i] % 16]; } } encoded_uri[k] = 0; -- 1.6.6.1 --------------000802010307040008080603 Content-Type: text/plain; name="0002-URI-encode-the-utf-8-filename-instead-of-a-partially.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-URI-encode-the-utf-8-filename-instead-of-a-partially.pa"; filename*1="tch" >From 1003e7809fbf2823e23b8dc8c7e3b46dfad0bcd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6cker?= Date: Sat, 13 Feb 2010 12:37:31 +0100 Subject: [PATCH 2/2] URI-encode the utf-8 filename instead of a partially URI-encoded gnome vfs uri --- libview/ev-view.c | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/libview/ev-view.c b/libview/ev-view.c index 1130d39..4fda860 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -5800,9 +5800,18 @@ ev_view_annotate (EvView *ev_view, gchar *uri, int page) EvDocumentInfo *p = ev_document_get_info(ev_view->document); + // get the real file path from evince + GFile *gfile = g_file_new_for_uri(uri); + char *filePath = g_file_get_path(gfile); + g_object_unref (gfile); + if (!filePath) { + printf("invalid file path"); + return; + } + tempSel = g_malloc(ANN_MAX_BUFFER_LEN); tempFileName = g_malloc(strlen(uri) * 4); - + if (!EV_IS_SELECTION (ev_view->document)) { strcmp(tempSel, ""); text = ""; @@ -5811,20 +5820,13 @@ ev_view_annotate (EvView *ev_view, gchar *uri, int page) text = get_selected_text (ev_view); encode_uri(tempSel, ANN_MAX_BUFFER_LEN, text); } - /// encode filename -#define ANN_FILE_PREFIX "file://" - if (strncmp(uri,ANN_FILE_PREFIX, strlen(ANN_FILE_PREFIX) ) == 0) { - // skip the prefix - encode_uri(tempFileName, - ANN_MAX_BUFFER_LEN, uri+strlen(ANN_FILE_PREFIX)); - } else { - encode_uri(tempFileName, ANN_MAX_BUFFER_LEN, uri); - } - + + encode_uri(tempFileName, ANN_MAX_BUFFER_LEN, filePath); + tempCommandLine = g_malloc(strlen(tempSel) + strlen(tempFileName) + 200); - printf("remember::::%s::::%s::::%s::::%d\n", p->title, uri, text, page); sprintf(tempCommandLine, "emacsclient 'org-protocol://remember://docview:%s::%d'", tempFileName, page+1); + printf("remember::::%s::::%s::::%s::::%d\n", p->title, filePath, text, page); printf("temp: [%s]\n", tempCommandLine); if (!g_spawn_command_line_async (tempCommandLine, &error)) { @@ -5836,6 +5838,8 @@ ev_view_annotate (EvView *ev_view, gchar *uri, int page) g_free (tempSel); g_free (tempCommandLine); g_free (tempFileName); + g_free (filePath); + #ifdef fork -- 1.6.6.1 --------------000802010307040008080603 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --------------000802010307040008080603--