[Xfce4-commits] <midori:master> Check method before caching and limit extension length
Christian Dywan
noreply at xfce.org
Fri Oct 23 01:24:06 CEST 2009
Updating branch refs/heads/master
to 86685cc0c9b64d624d5284fd65a02056440aaa5e (commit)
from ef67f2539ade340664b3c72a8f25ef981d945411 (commit)
commit 86685cc0c9b64d624d5284fd65a02056440aaa5e
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Oct 22 23:28:45 2009 +0200
Check method before caching and limit extension length
extensions/web-cache.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/extensions/web-cache.c b/extensions/web-cache.c
index 02d2f36..c0bb1e7 100644
--- a/extensions/web-cache.c
+++ b/extensions/web-cache.c
@@ -34,7 +34,6 @@ web_cache_get_cached_path (MidoriExtension* extension,
gchar* cached_filename;
gchar* cached_path;
- /* cache_path = midori_extension_get_string (extension, "path"); */
if (!cache_path)
cache_path = midori_extension_get_string (extension, "path");
checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
@@ -44,8 +43,12 @@ web_cache_get_cached_path (MidoriExtension* extension,
g_free (folder);
encoded = soup_uri_encode (uri, "/");
- ext = g_strrstr (encoded, ".");
+ ext = g_strdup (g_strrstr (encoded, "."));
+ /* Make sure ext isn't becoming too long */
+ if (ext && ext[0] && ext[1] && ext[2] && ext[3] && ext[4])
+ ext[4] = '\0';
cached_filename = g_strdup_printf ("%s%s", checksum, ext ? ext : "");
+ g_free (ext);
g_free (encoded);
g_free (checksum);
cached_path = g_build_filename (sub_path, cached_filename, NULL);
@@ -101,8 +104,6 @@ web_cache_load_error_cb (WebKitWebView* web_view,
GError* error,
MidoriExtension* extension)
{
- const gchar* provisional;
-
if (!(uri && g_str_has_prefix (uri, "http://")))
return FALSE;
@@ -188,7 +189,7 @@ web_cache_session_request_queued_cb (SoupSession* session,
SoupURI* soup_uri = soup_message_get_uri (msg);
gchar* uri = soup_uri ? soup_uri_to_string (soup_uri, FALSE) : g_strdup ("");
- if (g_str_has_prefix (uri, "http"))
+ if (g_str_has_prefix (uri, "http") && !g_strcmp0 (msg->method, "GET"))
{
gchar* filename = web_cache_get_cached_path (extension, uri);
@@ -221,6 +222,12 @@ web_cache_session_request_unqueued_cb (SoupSession* session,
SoupURI* soup_uri = soup_message_get_uri (msg);
gchar* uri = soup_uri ? soup_uri_to_string (soup_uri, FALSE) : NULL;
+ if (g_strcmp0 (msg->method, "GET"))
+ {
+ g_free (uri);
+ return;
+ }
+
/* g_debug ("request unqueued: %d %s", msg->status_code, uri); */
#if !HAVE_WEBKIT_RESOURCE_REQUEST
More information about the Xfce4-commits
mailing list