surf-oauth-popups.diff (1916B)
1 Description: Fix OAuth popups (window.open) being blocked 2 OAuth login flows use window.open() which WebKit reports as NAVIGATION_TYPE_OTHER 3 with is_user_gesture=true. The createview() logic was inverted — it blocked 4 user-gesture popups and allowed non-user-gesture ones. Additionally, 5 decidenewwindow() silently dropped all OTHER-type navigations. 6 7 This patch inverts the createview() check so user-initiated popups are allowed, 8 and adds handling in decidenewwindow() to open a new window for user-gesture 9 OTHER navigations. 10 11 Apply: patch -p1 < patches/surf-oauth-popups.diff 12 Unpatch: patch -R -p1 < patches/surf-oauth-popups.diff 13 14 diff --git a/surf.c b/surf.c 15 index 73eefe7..69497ed 100644 16 --- a/surf.c 17 +++ b/surf.c 18 @@ -1293,13 +1293,8 @@ createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c) 19 Client *n; 20 21 switch (webkit_navigation_action_get_navigation_type(a)) { 22 - case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ 23 - /* 24 - * popup windows of type “other” are almost always triggered 25 - * by user gesture, so inverse the logic here 26 - */ 27 -/* instead of this, compare destination uri to mouse-over uri for validating window */ 28 - if (webkit_navigation_action_is_user_gesture(a)) 29 + case WEBKIT_NAVIGATION_TYPE_OTHER: 30 + if (!webkit_navigation_action_is_user_gesture(a)) 31 return NULL; 32 case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */ 33 case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */ 34 @@ -1729,7 +1724,13 @@ decidenewwindow(WebKitPolicyDecision *d, Client *c) 35 webkit_navigation_action_get_request(a)); 36 newwindow(c, &arg, 0); 37 break; 38 - case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ 39 + case WEBKIT_NAVIGATION_TYPE_OTHER: 40 + if (webkit_navigation_action_is_user_gesture(a)) { 41 + arg.v = webkit_uri_request_get_uri( 42 + webkit_navigation_action_get_request(a)); 43 + newwindow(c, &arg, 0); 44 + } 45 + break; 46 default: 47 break; 48 }