summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2014-03-22 02:25:23 +0100
committerportix <portix@gmx.net>2014-03-22 02:25:23 +0100
commitef4e38c04341f9f1ec6c287fd07f9be4ae8728ae (patch)
tree8d868ec0d6993a868a4c3ee3eb58752367a5502f
parent519bf6c8d687202ee1a06d4a4604b08443c75ee7 (diff)
downloaddwb-ef4e38c04341f9f1ec6c287fd07f9be4ae8728ae.zip
Workaround for broken history if requests were blocked, fixes #403
-rw-r--r--src/dwb.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/dwb.c b/src/dwb.c
index 4c480d22..c6f5d9a4 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -1877,13 +1877,24 @@ dwb_history(Arg *a)
if (bf_list == NULL)
return STATUS_ERROR;
- int n = a->i == -1 ? MIN(webkit_web_back_forward_list_get_back_length(bf_list), NUMMOD) : MIN(webkit_web_back_forward_list_get_forward_length(bf_list), NUMMOD);
- WebKitWebHistoryItem *item = webkit_web_back_forward_list_get_nth_item(bf_list, a->i * n);
- if (a->n == OPEN_NORMAL)
+ int n = a->i == -1 ? MIN(webkit_web_back_forward_list_get_back_length(bf_list), NUMMOD) * a->i : MIN(webkit_web_back_forward_list_get_forward_length(bf_list), NUMMOD) * a->i;
+
+ WebKitWebHistoryItem *item = webkit_web_back_forward_list_get_nth_item(bf_list, n);
+ g_return_val_if_fail(item != NULL, STATUS_ERROR);
+
+ const char *uri = webkit_web_history_item_get_uri(item);
+
+ // dirty workaround because of a bug in webkit > 2.2: If some extension or
+ // the adblocker blocks a request it can break the history, fixes #403
+ if (n == -1 && g_strcmp0(webkit_web_view_get_uri(w), uri) == 0) {
+ item = webkit_web_back_forward_list_get_nth_item(bf_list, n-1);
+ }
+
+ if (a->n == OPEN_NORMAL) {
webkit_web_view_go_to_back_forward_item(w, item);
+ }
else
{
- const char *uri = webkit_web_history_item_get_uri(item);
if (a->n == OPEN_NEW_VIEW)
view_add(uri, dwb.state.background_tabs);
if (a->n == OPEN_NEW_WINDOW)