Don't attempt to open empty url by hinting.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 20 May 2017 22:32:20 +0000 (00:32 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 20 May 2017 22:39:41 +0000 (00:39 +0200)
There are pages where following links are used <a href="#"
onclick="...">...</a>. In this special case of href="#" the elements
should be clicked to let webkit decide how to handle the element instead
of opening current page with appended location mark.

src/scripts/hints.js

index 4e8fd28..f482bd7 100644 (file)
@@ -387,18 +387,19 @@ var hints = Object.freeze((function(){
         /* We call open() and click() in async mode to avoid return as fast as possible. */
         /* If we don't return immediately, the EvalJS dbus call will probably timeout and cause */
         /* errors. */
-        if (e.hasAttribute('href')) {
+        var href;
+        if ((href = e.getAttribute('href')) && href != '#') {
             if (newWin) {
                 /* Since the "noopener" vulnerability thing, it's not possible to set an anchor's */
                 /* target to _blank. Therefore, we can't simulate ctrl-click through _blank like we */
                 /* used to. Therefore, we limit ourselves to "window.open()" in cases we're firing a */
                 /* simple <a> link. In other cases, we fire the even normally. */
                 window.setTimeout(function() {
-                    window.open(e.getAttribute('href'), '_blank');
+                    window.open(href, '_blank');
                     }, 0
                 );
             } else {
-                window.location.href = e.getAttribute('href');
+                window.location.href = href;
             }
         } else {
             window.setTimeout(function() {e.click();}, 0);