ecma/kjs_window.cpp Window::goURL

Koos Vriezen koos.vriezen at xs4all.nl
Thu Apr 8 22:26:01 BST 2004


On Sat, Jan 10, 2004 at 10:49:15PM +0100, Koos Vriezen wrote:
> On Sat, Jan 10, 2004 at 10:32:58PM +0100, David Faure wrote:
> > On Saturday 10 January 2004 21:32, Koos Vriezen wrote:
> > > Hi,
> > > 
> > > Window::goURL does not do 'location.href = location.href' for a reload. Couldn't
> > > find where this was added in the cvs logs, but
> > > // Check if the URL is the current one. No [infinite] redirect in that case
> > > suggest it fixes something, but it breaks "Luister Live" on http://www.radio1.be.
> > > (See #72304 for the application)
> > 
> > cvs ann -r1.286 kjs_window.cpp | grep infinite
> > 1.270        (faure    30-Jul-02):           // Check if the URL is the current one. No [infinite] redirect in that case.
> > 
> > cvs log -r1.270 kjs_window.cpp
> > Fix for location='url', infinitely looping on https://start.telebank.co.il
> 
> Fix breaks compatibility with other browsers
> 
> <html><body onLoad='alert("hi")' onClick='location.href=location.href'></body></html>
> 
> see the difference with mozilla (and most probably ie too)  and konqueror.
> 
> Indeed mozilla hangs on
> <html><body onLoad='location.href=location.href'></body></html>
> but konqueror doesn't make much of https://start.telebank.co.il either ...
> 
> Anyway, we can't ignore side effects of eg cookies and assume reopening the same
> url is pointless.

Ok, found a case that behaves different in current compared to mozilla:
  <BODY onLoad="document.location=#myanchor">
This one doesn't trigger reloads on at least mozilla and I thing we should fix
it. Patch attached!

Koos
-------------- next part --------------
Index: ecma/kjs_window.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.373
diff -u -3 -p -r1.373 kjs_window.cpp
--- ecma/kjs_window.cpp	24 Feb 2004 16:11:55 -0000	1.373
+++ ecma/kjs_window.cpp	8 Apr 2004 21:20:37 -0000
@@ -1075,22 +1075,26 @@ void Window::goURL(ExecState* exec, cons
   Window* active = Window::retrieveActive(exec);
   // Complete the URL using the "active part" (running interpreter)
   if (active->part()) {
-    QString dstUrl = active->part()->htmlDocument().completeURL(url).string();
-    KURL dst( dstUrl );
-    KURL partURL( m_part->url() );
-    // Remove refs for the comparison
-    dst.setRef( QString::null );
-    partURL.setRef( QString::null );
-    kdDebug(6070) << "Window::goURL dstUrl=" << dst.prettyURL() << " partURL=" << partURL.prettyURL()
+    if (url[0] == QChar('#')) {
+      m_part->gotoAnchor(url.mid(1));
+    } else {
+      QString dstUrl = active->part()->htmlDocument().completeURL(url).string();
+      KURL dst( dstUrl );
+      KURL partURL( m_part->url() );
+      // Remove refs for the comparison
+      dst.setRef( QString::null );
+      partURL.setRef( QString::null );
+      kdDebug(6070) << "Window::goURL dstUrl=" << dst.prettyURL() << " partURL=" << partURL.prettyURL()
                    << " identical: " << partURL.equals( dst, true ) << endl;
 
-    // check if we're allowed to inject javascript
-    // SYNC check with khtml_part.cpp::slotRedirect!
-    if ( isSafeScript(exec) ||
+      // check if we're allowed to inject javascript
+      // SYNC check with khtml_part.cpp::slotRedirect!
+      if ( isSafeScript(exec) ||
             dstUrl.find(QString::fromLatin1("javascript:"), 0, false) != 0 )
-      m_part->scheduleRedirection(-1,
+          m_part->scheduleRedirection(-1,
                                 dstUrl,
                                   lockHistory);
+    }
   }
 }
 


More information about the kfm-devel mailing list