Index: http.cc
===================================================================
RCS file: /home/kde/kdelibs/kioslave/http/http.cc,v
retrieving revision 1.470.2.20
diff -u -r1.470.2.20 http.cc
--- http.cc	7 Dec 2002 16:17:53 -0000	1.470.2.20
+++ http.cc	4 Jul 2003 13:29:57 -0000
@@ -195,20 +195,33 @@
   m_maxCacheAge = config()->readNumEntry("MaxCacheAge", DEFAULT_MAX_CACHE_AGE);
   m_request.window = config()->readEntry("window-id");
 
-  bool sendReferrer = config()->readBoolEntry("SendReferrer", true);
-  if ( sendReferrer )
-     m_request.referrer = metaData("referrer");
-  else
-     m_request.referrer = QString::null;
-     
-  if (!m_request.referrer.startsWith("http"))
+
+  m_request.referrer = QString::null;
+  if ( config()->readBoolEntry("SendReferrer", true) )
   {
-     if (m_request.referrer.startsWith("webdav"))
-        m_request.referrer.replace(0, 6, "http");
-     else
-        m_request.referrer = QString::null;
+     KURL referrerURL = metaData("referrer");
+     if (referrerURL.isValid())
+     {
+        // Sanitize
+        QString protocol = referrerURL.protocol();
+        if (protocol.startsWith("webdav"))
+        {
+           protocol.replace(0, 6, "http");
+           referrerURL.setProtocol(protocol);
+        }
+        
+        if ((protocol == "http") || 
+            ((protocol == "https") && ((m_protocol == "https") || (m_protocol == "webdavs")))
+           )
+        {
+           referrerURL.setRef(QString::null);
+           referrerURL.setUser(QString::null);
+           referrerURL.setPass(QString::null);
+           m_request.referrer = referrerURL.url();
+        }
+     }
   }
-
+  
   if ( config()->readBoolEntry("SendLanguageSettings", true) )
   {
       m_request.charsets = config()->readEntry( "Charsets", "iso-8859-1" );