Smart bookmarks: expand space to +
John Lenz <[email protected]> Thu, 09 Dec 2004 19:52:16 +0000
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <1102621936l.6949l.0l@hydra> |
Hi. For the wikipedia search page, if multiple words are searched
for, the correct url is something like
http://www.wikipedia.org/w/wiki.phtml?search=Hello+world
Using http://www.wikipedia.org/w/wiki.phtml?search=%s as the smart
bookmark does not work when two words are searched for, because
galeon expands the space to %20.
The following patch expands %+ in the smart url to a list of words
seperated by + instead of %20. It is kinda a hack, since galeon
is calling gnome_vfs_escape_string, which converts the space into
a %20, so when expanding the %+, we replace all %20 in the argument
with a +.
After this patch, the string
http://www.wikipedia.org/w/wiki.phtml?search=%+
works for searching wikipedia from the smart bookmark bar.
(I am not subscribed to the list so add me to the CC)
John
--- galeon-1.3.18/bookmarks/bookmarks.c~plus
+++ galeon-1.3.18/bookmarks/bookmarks.c
@@ -1820,6 +1820,8 @@
GString *s;
gchar *t1;
gchar *t2;
+ gchar *t3;
+ gchar *t4;
gchar **encoded_args;
gchar *encoding;
gchar *smarturl_only;
@@ -1899,6 +1901,33 @@
}
t1 = t2 + 2;
}
+ /* if there is a remaining %+, put all the remaining args in
+ it, seperated by a + sign. Note: gnome_vfs_esacpe_string
+ replaced all spaces in each argument with %20.
+ So we first replace %20 by +. */
+ t2 = strstr(t1, "%+");
+ if (t2)
+ {
+ g_string_append_len (s, t1, t2 - t1);
+ while (*args != NULL)
+ {
+ t4 = *args;
+ while ((t3 = strstr(t4, "%20")))
+ {
+ g_string_append_len(s, t4, t3 - t4);
+ g_string_append(s, "+");
+ t4 = t3 + 3;
+ }
+ g_string_append (s, t4);
+ args++;
+ if (*args != NULL)
+ {
+ g_string_append (s, "+");
+ }
+ }
+ t1 = t2 + 2;
+ }
+
g_string_append (s, t1);
ret = s->str;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/