[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [POSSIBLE PATCH] Fix KDE4 Konqueror proxy settings
From:       "Dmitry Ivanov" <vonami () gmail ! com>
Date:       2007-09-20 11:28:51
Message-ID: 6df8d8b90709200428x473eb9ccla99b0f1f14022dad () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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?

[Attachment #5 (text/html)]

Hello KDE team!<br><br>I have been following the KDE4 development since a \
couple<br>of months and recently decided to give KDE 4 a try as my default<br>desktop \
environment.<br><br>Tried Konqueror but couldn&#39;t setup it to use a proxy server. \
<br>Whatever I type in the manual proxy configuration dialog<br>it complains \
&quot;The proxy settings you specified are invalid&quot;.<br><br>The patch in the \
attached file fixed it for me. I&#39;m not sure<br>whether I got it right so I&#39;ll \
comment on my changes. \
<br><br><br>===================================================================<br>--- \
settings/kio/kmanualproxydlg.cpp&nbsp;&nbsp;&nbsp; (revision 713920)<br>+++ \
settings/kio/kmanualproxydlg.cpp&nbsp;&nbsp;&nbsp; (working copy)<br>@@ -78,6 +78,8 \
@@<br> <br>&nbsp;&nbsp;&nbsp;&nbsp; connect( mDlg-&gt;leHttp, \
SIGNAL(textChanged(const QString&amp;)), SLOT(textChanged(const QString&amp;)) \
);<br>&nbsp;&nbsp;&nbsp;&nbsp; connect( mDlg-&gt;sbHttp, SIGNAL(valueChanged(int)), \
SLOT(valueChanged (int)) );<br>+<br>+&nbsp;&nbsp;&nbsp; connect( this, \
SIGNAL(okClicked()), this, SLOT(slotOk())); <br>&nbsp;}<br><br>&nbsp;void \
KManualProxyDlg::setProxyData( const KProxyData &amp;data )<br><br><br>Comment: This \
one is trivial. Possibly the orphaned slot is a result of porting to \
KDE/Qt4.<br><br><br>@@ -93,7 +95,7 \
@@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( port &lt;= 0 ) \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; port = \
DEFAULT_PROXY_PORT;<br><br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url.setPort( 0 \
);<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url.setPort( -1 \
);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mDlg-&gt;leHttp-&gt;setText( \
url.url() );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
mDlg-&gt;sbHttp-&gt;setValue( port );<br>&nbsp;&nbsp;&nbsp;&nbsp; } <br>@@ -124,7 \
+126,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( port \
&lt;= 0 )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
port = DEFAULT_PROXY_PORT;<br><br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
url.setPort( 0 );<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
url.setPort( -1 );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
mDlg-&gt;leHttps-&gt;setText( url.url () \
);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
mDlg-&gt;sbHttps-&gt;setValue( port );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
}<br>@@ -138,7 +140,7 \
@@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( port &lt;= 0 \
)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
port = DEFAULT_PROXY_PORT;<br><br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
url.setPort( 0 );<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  \
url.setPort( -1 );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
mDlg-&gt;leFtp-&gt;setText( url.url() \
);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
mDlg-&gt;sbFtp-&gt;setValue( port );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
}<br><br>Comment: The Qt4 docs state it clearly: -1 means the port is \
unspecified.<br> One more result of porting?<br><br><br>@@ -412,8 +414,8 \
@@<br><br>&nbsp;&nbsp;&nbsp;&nbsp; // If the typed URL is malformed, and the filters \
cannot filter it<br>&nbsp;&nbsp;&nbsp;&nbsp; // then it must be an invalid \
entry.<br>-&nbsp;&nbsp;&nbsp; if( !(url.isValid() || \
KUriFilter::self()-&gt;filterUri(url, filters)) &amp;&amp; \
<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !url.hasHost() \
)<br>+&nbsp;&nbsp;&nbsp; if( !(url.isValid() &amp;&amp; \
KUriFilter::self()-&gt;filterUri(url, filters) \
&amp;&amp;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url.hasHost()) \
)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return \
false;<br><br>&nbsp;&nbsp;&nbsp;&nbsp; QString host (url.host());<br> <br>Comment: \
This logic turned out to be broken. Let me explain.<br><br>If I type &quot;<a \
href="http://10.242.100.5">10.242.100.5</a>&quot; in the http proxy field this \
function<br>( isValidURL( const QString&amp; _url, KUrl* result ) ) constructs a KUrl \
<br>object from the entered text:<br><br>KUrl url(_url);<br><br>If you add a few \
debug lines like<br><br>&nbsp; kDebug() &lt;&lt; &quot;got url = &quot; &lt;&lt; \
url;<br>&nbsp; kDebug() &lt;&lt; &quot;got url.url = &quot; &lt;&lt;  \
url.url();<br>&nbsp; kDebug() &lt;&lt; &quot;got url.scheme = &quot; &lt;&lt; \
url.scheme();<br>&nbsp; kDebug() &lt;&lt; &quot;got url.host = &quot; &lt;&lt; \
url.host();<br>&nbsp; kDebug() &lt;&lt; &quot;got url.port = &quot; &lt;&lt; url.port \
();<br>&nbsp; kDebug() &lt;&lt; &quot;got url.fragment = &quot; &lt;&lt; \
url.fragment();<br>&nbsp; kDebug() &lt;&lt; &quot;got url.path = &quot; &lt;&lt; \
url.path();<br><br>you will get:<br><br>&nbsp; konqueror(25730) \
KManualProxyDlg::isValidURL: got  url.url =&nbsp; &quot;<a \
href="http://10.242.100.5">10.242.100.5</a>&quot;<br>&nbsp; konqueror(25730) \
KManualProxyDlg::isValidURL: got url.scheme =&nbsp; &quot;&quot;<br>&nbsp; \
konqueror(25730) KManualProxyDlg::isValidURL: got url.host =&nbsp; &quot;&quot; \
<br>&nbsp; konqueror(25730) KManualProxyDlg::isValidURL: got url.port =&nbsp; \
-1<br>&nbsp; konqueror(25730) KManualProxyDlg::isValidURL: got url.fragment =&nbsp; \
&quot;&quot;<br>&nbsp; konqueror(25730) KManualProxyDlg::isValidURL: got url.path \
=&nbsp; &quot; <a href="http://10.242.100.5">10.242.100.5</a>&quot;<br><br>Note that \
the host part is empty and &quot;<a href="http://10.242.100.5">10.242.100.5</a>&quot; \
actually became the path part<br>of the url. Nonetheless url.isValid () in the \
&quot;if&quot; statement returns true<br>and therefore \
KUriFilter::self()-&gt;filterUri(url, filters) is not executed. We end<br>up with a \
broken url.<br><br>I guess that KDE/Qt3&#39;s KUrl class returns false in this case \
and then <br>KUriFilter::self()-&gt;filterUri(url, filters) converts the url to \
canonical form.<br>So I have changed the logic the way you see above.<br><br>With \
this patch Konqueror accepts proxy settings and works fine via<br>a proxy server. \
<br><br>Best regards,<br>Dmitry Ivanov<br clear="all"><br>-- <br>A: Because it \
destroys the flow of the conversation<br>Q: Why is top-posting bad?


["konq-fix-proxy-settings.patch" (text/x-patch)]

Index: settings/kio/kmanualproxydlg.cpp
===================================================================
--- 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 )
@@ -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 );
       }
@@ -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());


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic