[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#378868: apt: http method uses absoluteURI when Proxy is set to "false"



The problem is both with the URI class (which has a simplistic empty()
method) and the http method (which should really be checking for a valid
method and hostname).  Acquire::http::proxy's string is passed to the
URI class, which parses it.  The http method then calls URI's empty() to
see whether it should be using a proxy or not.  The value "false" is set
as the method, and the hostname is "".  The http method should really be
checking if both the method and hostname fields are set to something
before assuming that it should use a proxy.

So, the attached patch changes URI::empty() to check if the Access and
Host strings are empty; if either of them are, then consider the URI to
be empty. Special case "file" and "copy", allowing them to have an empty
Host string.

A better fix might be to drop URI::empty altogether, and have the
individual methods check whether or not they've been fed a valid string.
That would be a much larger fix though.

=== modified file 'apt-pkg/contrib/strutl.cc'
--- apt-pkg/contrib/strutl.cc	
+++ apt-pkg/contrib/strutl.cc	
@@ -1165,6 +1165,24 @@
    return Res;
 }
 									/*}}}*/
+// URI::empty - Determine whether a URI is filled in or not		/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool URI::empty()
+{
+   if (Access.empty())
+       return true;
+   else if (Host.empty())
+   {
+       if (Access != "file" && Access != "copy")
+           return true;
+           // methods that aren't allowed to have empty Host fields:
+           // http, ftp, cdrom, rsh, ssh.
+   }
+   return false;
+}
+
+									/*}}}*/
 // URI::SiteOnly - Return the schema and site for the URI		/*{{{*/
 // ---------------------------------------------------------------------
 /* */

=== modified file 'apt-pkg/contrib/strutl.h'
--- apt-pkg/contrib/strutl.h	
+++ apt-pkg/contrib/strutl.h	
@@ -114,7 +114,7 @@
    
    operator string();
    inline void operator =(const string &From) {CopyFrom(From);};
-   inline bool empty() {return Access.empty();};
+   bool empty();
    static string SiteOnly(const string &URI);
    
    URI(string Path) {CopyFrom(Path);};


Reply to: