Fix url cache bug

This commit is contained in:
jun7 2018-06-13 18:59:30 +09:00
parent a3c023e648
commit d0ac830658

View File

@ -182,28 +182,44 @@ ephy_uri_tester_is_matched (EphyUriTester *tester,
const char *page_uri, const char *page_uri,
gboolean whitelist) gboolean whitelist)
{ {
/*
char *value; char *value;
*/
GHashTable *urlcache = tester->urlcache; GHashTable *urlcache = tester->urlcache;
if (whitelist) if (whitelist)
urlcache = tester->whitelisted_urlcache; urlcache = tester->whitelisted_urlcache;
/* Check cached URLs first. */ /* Check cached URLs first. */
/*
if ((value = g_hash_table_lookup (urlcache, req_uri))) if ((value = g_hash_table_lookup (urlcache, req_uri)))
return GPOINTER_TO_INT (value); return GPOINTER_TO_INT (value);
*/
char f;
if ((f = GPOINTER_TO_INT(g_hash_table_lookup(urlcache, req_uri))))
return f == 'T';
/* Look for a match either by key or by pattern. */ /* Look for a match either by key or by pattern. */
if (ephy_uri_tester_is_matched_by_key (tester, opts, req_uri, page_uri, whitelist)) { if (ephy_uri_tester_is_matched_by_key (tester, opts, req_uri, page_uri, whitelist)) {
/*
g_hash_table_insert (urlcache, g_strdup (req_uri), g_strdup ("1")); g_hash_table_insert (urlcache, g_strdup (req_uri), g_strdup ("1"));
*/
g_hash_table_insert(urlcache, g_strdup(req_uri), GINT_TO_POINTER('T'));
return TRUE; return TRUE;
} }
/* Matching by pattern is pretty expensive, so do it if needed only. */ /* Matching by pattern is pretty expensive, so do it if needed only. */
if (ephy_uri_tester_is_matched_by_pattern (tester, req_uri, page_uri, whitelist)) { if (ephy_uri_tester_is_matched_by_pattern (tester, req_uri, page_uri, whitelist)) {
/*
g_hash_table_insert (urlcache, g_strdup (req_uri), GINT_TO_POINTER (TRUE)); g_hash_table_insert (urlcache, g_strdup (req_uri), GINT_TO_POINTER (TRUE));
*/
g_hash_table_insert(urlcache, g_strdup(req_uri), GINT_TO_POINTER('T'));
return TRUE; return TRUE;
} }
/*
g_hash_table_insert (urlcache, g_strdup (req_uri), GINT_TO_POINTER (FALSE)); g_hash_table_insert (urlcache, g_strdup (req_uri), GINT_TO_POINTER (FALSE));
*/
g_hash_table_insert(urlcache, g_strdup(req_uri), GINT_TO_POINTER('F'));
return FALSE; return FALSE;
} }