[commit: Cabal] master: Workaround for a url parsing bug that breaks http proxies that need auth (53d23ed)

Ian Lynagh igloo at earth.li
Fri Jun 24 02:01:13 CEST 2011


Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/53d23ede38c8fbe64be9a543b56297babbe38d62

>---------------------------------------------------------------

commit 53d23ede38c8fbe64be9a543b56297babbe38d62
Author: Duncan Coutts <duncan at haskell.org>
Date:   Thu Dec 18 16:55:41 2008 +0000

    Workaround for a url parsing bug that breaks http proxies that need auth
    Diagnosis and patch from Valery V. Vorotyntsev.

>---------------------------------------------------------------

 cabal-install/Distribution/Client/HttpUtils.hs |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/cabal-install/Distribution/Client/HttpUtils.hs b/cabal-install/Distribution/Client/HttpUtils.hs
index ac9aafc..fb97b1a 100644
--- a/cabal-install/Distribution/Client/HttpUtils.hs
+++ b/cabal-install/Distribution/Client/HttpUtils.hs
@@ -101,9 +101,17 @@ parseHttpProxy str = join
   where
     parseHttpURI str' = case parseAbsoluteURI str' of
       Just uri at URI { uriAuthority = Just _ }
-         -> Just uri
+         -> Just (fixUserInfo uri)
       _  -> Nothing
 
+fixUserInfo :: URI -> URI
+fixUserInfo uri = uri{ uriAuthority = f `fmap` uriAuthority uri }
+    where
+      f a at URIAuth{ uriUserInfo = s } =
+          a{ uriUserInfo = case reverse s of
+                             '@':s' -> reverse s'
+                             _      -> s
+           }
 uri2proxy :: URI -> Maybe Proxy
 uri2proxy uri at URI{ uriScheme = "http:"
                  , uriAuthority = Just (URIAuth auth' host port)





More information about the Cvs-libraries mailing list