From kde-devel Thu Sep 20 11:28:51 2007 From: "Dmitry Ivanov" Date: Thu, 20 Sep 2007 11:28:51 +0000 To: kde-devel Subject: [POSSIBLE PATCH] Fix KDE4 Konqueror proxy settings Message-Id: <6df8d8b90709200428x473eb9ccla99b0f1f14022dad () mail ! gmail ! com> X-MARC-Message: https://marc.info/?l=kde-devel&m=119028779303232 MIME-Version: 1 Content-Type: multipart/mixed; boundary="------=_Part_34963_15344145.1190287731983" ------=_Part_34963_15344145.1190287731983 Content-Type: multipart/alternative; boundary="----=_Part_34964_28716386.1190287731983" ------=_Part_34964_28716386.1190287731983 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello KDE team! I have been following the KDE4 development since a couple of months and recently decided to give KDE 4 a try as my default desktop environment. Tried Konqueror but couldn't setup it to use a proxy server. Whatever I type in the manual proxy configuration dialog it complains "The proxy settings you specified are invalid". The patch in the attached file fixed it for me. I'm not sure whether I got it right so I'll comment on my changes. =================================================================== --- settings/kio/kmanualproxydlg.cpp (revision 713920) +++ settings/kio/kmanualproxydlg.cpp (working copy) @@ -78,6 +78,8 @@ connect( mDlg->leHttp, SIGNAL(textChanged(const QString&)), SLOT(textChanged(const QString&)) ); connect( mDlg->sbHttp, SIGNAL(valueChanged(int)), SLOT(valueChanged (int)) ); + + connect( this, SIGNAL(okClicked()), this, SLOT(slotOk())); } void KManualProxyDlg::setProxyData( const KProxyData &data ) Comment: This one is trivial. Possibly the orphaned slot is a result of porting to KDE/Qt4. @@ -93,7 +95,7 @@ if ( port <= 0 ) port = DEFAULT_PROXY_PORT; - url.setPort( 0 ); + url.setPort( -1 ); mDlg->leHttp->setText( url.url() ); mDlg->sbHttp->setValue( port ); } @@ -124,7 +126,7 @@ if ( port <= 0 ) port = DEFAULT_PROXY_PORT; - url.setPort( 0 ); + url.setPort( -1 ); mDlg->leHttps->setText( url.url() ); mDlg->sbHttps->setValue( port ); } @@ -138,7 +140,7 @@ if ( port <= 0 ) port = DEFAULT_PROXY_PORT; - url.setPort( 0 ); + url.setPort( -1 ); mDlg->leFtp->setText( url.url() ); mDlg->sbFtp->setValue( port ); } Comment: The Qt4 docs state it clearly: -1 means the port is unspecified. One more result of porting? @@ -412,8 +414,8 @@ // If the typed URL is malformed, and the filters cannot filter it // then it must be an invalid entry. - if( !(url.isValid() || KUriFilter::self()->filterUri(url, filters)) && - !url.hasHost() ) + if( !(url.isValid() && KUriFilter::self()->filterUri(url, filters) && + url.hasHost()) ) return false; QString host (url.host()); Comment: This logic turned out to be broken. Let me explain. If I type "10.242.100.5" in the http proxy field this function ( isValidURL( const QString& _url, KUrl* result ) ) constructs a KUrl object from the entered text: KUrl url(_url); If you add a few debug lines like kDebug() << "got url = " << url; kDebug() << "got url.url = " << url.url(); kDebug() << "got url.scheme = " << url.scheme(); kDebug() << "got url.host = " << url.host(); kDebug() << "got url.port = " << url.port(); kDebug() << "got url.fragment = " << url.fragment(); kDebug() << "got url.path = " << url.path(); you will get: konqueror(25730) KManualProxyDlg::isValidURL: got url.url = "10.242.100.5 " konqueror(25730) KManualProxyDlg::isValidURL: got url.scheme = "" konqueror(25730) KManualProxyDlg::isValidURL: got url.host = "" konqueror(25730) KManualProxyDlg::isValidURL: got url.port = -1 konqueror(25730) KManualProxyDlg::isValidURL: got url.fragment = "" konqueror(25730) KManualProxyDlg::isValidURL: got url.path = " 10.242.100.5" Note that the host part is empty and "10.242.100.5" actually became the path part of the url. Nonetheless url.isValid() in the "if" statement returns true and therefore KUriFilter::self()->filterUri(url, filters) is not executed. We end up with a broken url. I guess that KDE/Qt3's KUrl class returns false in this case and then KUriFilter::self()->filterUri(url, filters) converts the url to canonical form. So I have changed the logic the way you see above. With this patch Konqueror accepts proxy settings and works fine via a proxy server. Best regards, Dmitry Ivanov -- A: Because it destroys the flow of the conversation Q: Why is top-posting bad? ------=_Part_34964_28716386.1190287731983 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello KDE team!

I have been following the KDE4 development since a couple
of months and recently decided to give KDE 4 a try as my default
desktop environment.

Tried Konqueror but couldn't setup it to use a proxy server.
Whatever I type in the manual proxy configuration dialog
it complains "The proxy settings you specified are invalid".

The patch in the attached file fixed it for me. I'm not sure
whether I got it right so I'll comment on my changes.


===================================================================
--- settings/kio/kmanualproxydlg.cpp    (revision 713920)
+++ settings/kio/kmanualproxydlg.cpp    (working copy)
@@ -78,6 +78,8 @@

     connect( mDlg->leHttp, SIGNAL(textChanged(const QString&)), SLOT(textChanged(const QString&)) );
     connect( mDlg->sbHttp, SIGNAL(valueChanged(int)), SLOT(valueChanged (int)) );
+
+    connect( this, SIGNAL(okClicked()), this, SLOT(slotOk()));
 }

 void KManualProxyDlg::setProxyData( const KProxyData &data )


Comment: This one is trivial. Possibly the orphaned slot is a result of porting to KDE/Qt4.


@@ -93,7 +95,7 @@
         if ( port <= 0 )
             port = DEFAULT_PROXY_PORT;

-        url.setPort( 0 );
+        url.setPort( -1 );
         mDlg->leHttp->setText( url.url() );
         mDlg->sbHttp->setValue( port );
     }
@@ -124,7 +126,7 @@
           if ( port <= 0 )
               port = DEFAULT_PROXY_PORT;

-          url.setPort( 0 );
+          url.setPort( -1 );
           mDlg->leHttps->setText( url.url () );
           mDlg->sbHttps->setValue( port );
       }
@@ -138,7 +140,7 @@
           if ( port <= 0 )
               port = DEFAULT_PROXY_PORT;

-          url.setPort( 0 );
+          url.setPort( -1 );
           mDlg->leFtp->setText( url.url() );
           mDlg->sbFtp->setValue( port );
       }

Comment: The Qt4 docs state it clearly: -1 means the port is unspecified.
One more result of porting?


@@ -412,8 +414,8 @@

     // If the typed URL is malformed, and the filters cannot filter it
     // then it must be an invalid entry.
-    if( !(url.isValid() || KUriFilter::self()->filterUri(url, filters)) &&
-        !url.hasHost() )
+    if( !(url.isValid() && KUriFilter::self()->filterUri(url, filters) &&
+        url.hasHost()) )
       return false;

     QString host (url.host());

Comment: This logic turned out to be broken. Let me explain.

If I type "10.242.100.5" in the http proxy field this function
( isValidURL( const QString& _url, KUrl* result ) ) constructs a KUrl
object from the entered text:

KUrl url(_url);

If you add a few debug lines like

  kDebug() << "got url = " << url;
  kDebug() << "got url.url = " << url.url();
  kDebug() << "got url.scheme = " << url.scheme();
  kDebug() << "got url.host = " << url.host();
  kDebug() << "got url.port = " << url.port ();
  kDebug() << "got url.fragment = " << url.fragment();
  kDebug() << "got url.path = " << url.path();

you will get:

  konqueror(25730) KManualProxyDlg::isValidURL: got url.url =  "10.242.100.5"
  konqueror(25730) KManualProxyDlg::isValidURL: got url.scheme =  ""
  konqueror(25730) KManualProxyDlg::isValidURL: got url.host =  ""
  konqueror(25730) KManualProxyDlg::isValidURL: got url.port =  -1
  konqueror(25730) KManualProxyDlg::isValidURL: got url.fragment =  ""
  konqueror(25730) KManualProxyDlg::isValidURL: got url.path =  " 10.242.100.5"

Note that the host part is empty and "10.242.100.5" actually became the path part
of the url. Nonetheless url.isValid () in the "if" statement returns true
and therefore KUriFilter::self()->filterUri(url, filters) is not executed. We end
up with a broken url.

I guess that KDE/Qt3's KUrl class returns false in this case and then
KUriFilter::self()->filterUri(url, filters) converts the url to canonical form.
So I have changed the logic the way you see above.

With this patch Konqueror accepts proxy settings and works fine via
a proxy server.

Best regards,
Dmitry Ivanov

--
A: Because it destroys the flow of the conversation
Q: Why is top-posting bad? ------=_Part_34964_28716386.1190287731983-- ------=_Part_34963_15344145.1190287731983 Content-Type: text/x-patch; name="konq-fix-proxy-settings.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="konq-fix-proxy-settings.patch" X-Attachment-Id: f_f6t6gs4v SW5kZXg6IHNldHRpbmdzL2tpby9rbWFudWFscHJveHlkbGcuY3BwCj09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIHNl dHRpbmdzL2tpby9rbWFudWFscHJveHlkbGcuY3BwCShyZXZpc2lvbiA3MTM5MjApCisrKyBzZXR0 aW5ncy9raW8va21hbnVhbHByb3h5ZGxnLmNwcAkod29ya2luZyBjb3B5KQpAQCAtNzgsNiArNzgs OCBAQAogCiAgICAgY29ubmVjdCggbURsZy0+bGVIdHRwLCBTSUdOQUwodGV4dENoYW5nZWQoY29u c3QgUVN0cmluZyYpKSwgU0xPVCh0ZXh0Q2hhbmdlZChjb25zdCBRU3RyaW5nJikpICk7CiAgICAg Y29ubmVjdCggbURsZy0+c2JIdHRwLCBTSUdOQUwodmFsdWVDaGFuZ2VkKGludCkpLCBTTE9UKHZh bHVlQ2hhbmdlZCAoaW50KSkgKTsKKyAgICAKKyAgICBjb25uZWN0KCB0aGlzLCBTSUdOQUwob2tD bGlja2VkKCkpLCB0aGlzLCBTTE9UKHNsb3RPaygpKSk7CiB9CiAKIHZvaWQgS01hbnVhbFByb3h5 RGxnOjpzZXRQcm94eURhdGEoIGNvbnN0IEtQcm94eURhdGEgJmRhdGEgKQpAQCAtOTMsNyArOTUs NyBAQAogICAgICAgICBpZiAoIHBvcnQgPD0gMCApCiAgICAgICAgICAgICBwb3J0ID0gREVGQVVM VF9QUk9YWV9QT1JUOwogCi0gICAgICAgIHVybC5zZXRQb3J0KCAwICk7CisgICAgICAgIHVybC5z ZXRQb3J0KCAtMSApOwogICAgICAgICBtRGxnLT5sZUh0dHAtPnNldFRleHQoIHVybC51cmwoKSAp OwogICAgICAgICBtRGxnLT5zYkh0dHAtPnNldFZhbHVlKCBwb3J0ICk7CiAgICAgfQpAQCAtMTI0 LDcgKzEyNiw3IEBACiAgICAgICAgICAgaWYgKCBwb3J0IDw9IDAgKQogICAgICAgICAgICAgICBw b3J0ID0gREVGQVVMVF9QUk9YWV9QT1JUOwogCi0gICAgICAgICAgdXJsLnNldFBvcnQoIDAgKTsK KyAgICAgICAgICB1cmwuc2V0UG9ydCggLTEgKTsKICAgICAgICAgICBtRGxnLT5sZUh0dHBzLT5z ZXRUZXh0KCB1cmwudXJsKCkgKTsKICAgICAgICAgICBtRGxnLT5zYkh0dHBzLT5zZXRWYWx1ZSgg cG9ydCApOwogICAgICAgfQpAQCAtMTM4LDcgKzE0MCw3IEBACiAgICAgICAgICAgaWYgKCBwb3J0 IDw9IDAgKQogICAgICAgICAgICAgICBwb3J0ID0gREVGQVVMVF9QUk9YWV9QT1JUOwogCi0gICAg ICAgICAgdXJsLnNldFBvcnQoIDAgKTsKKyAgICAgICAgICB1cmwuc2V0UG9ydCggLTEgKTsKICAg ICAgICAgICBtRGxnLT5sZUZ0cC0+c2V0VGV4dCggdXJsLnVybCgpICk7CiAgICAgICAgICAgbURs Zy0+c2JGdHAtPnNldFZhbHVlKCBwb3J0ICk7CiAgICAgICB9CkBAIC00MTIsOCArNDE0LDggQEAK IAogICAgIC8vIElmIHRoZSB0eXBlZCBVUkwgaXMgbWFsZm9ybWVkLCBhbmQgdGhlIGZpbHRlcnMg Y2Fubm90IGZpbHRlciBpdAogICAgIC8vIHRoZW4gaXQgbXVzdCBiZSBhbiBpbnZhbGlkIGVudHJ5 LgotICAgIGlmKCAhKHVybC5pc1ZhbGlkKCkgfHwgS1VyaUZpbHRlcjo6c2VsZigpLT5maWx0ZXJV cmkodXJsLCBmaWx0ZXJzKSkgJiYKLSAgICAgICAgIXVybC5oYXNIb3N0KCkgKQorICAgIGlmKCAh KHVybC5pc1ZhbGlkKCkgJiYgS1VyaUZpbHRlcjo6c2VsZigpLT5maWx0ZXJVcmkodXJsLCBmaWx0 ZXJzKSAmJgorICAgICAgICB1cmwuaGFzSG9zdCgpKSApCiAgICAgICByZXR1cm4gZmFsc2U7CiAK ICAgICBRU3RyaW5nIGhvc3QgKHVybC5ob3N0KCkpOwo= ------=_Part_34963_15344145.1190287731983 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << ------=_Part_34963_15344145.1190287731983--