diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:54:51 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:54:51 +0000 |
commit | 54cf15cb909b722a69d73850ad66bfad6cee66fa (patch) | |
tree | edc1ffb181372cd4be74c0e7af0d0c08e5ac8f23 /apt-pkg/contrib/strutl.cc | |
parent | 31a0531ddea0f1737b607cde4ae40c22493bf72c (diff) |
Beautified URI printing to not include passwords
Author: jgg
Date: 1999-10-17 07:30:23 GMT
Beautified URI printing to not include passwords
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 1af8c4304..93a2b39cd 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: strutl.cc,v 1.29 1999/08/28 01:49:08 jgg Exp $ +// $Id: strutl.cc,v 1.30 1999/10/17 07:30:23 jgg Exp $ /* ###################################################################### String Util - Some usefull string functions. @@ -326,11 +326,14 @@ string SubstVar(string Str,string Subst,string Contents) file name should be unique and never occur again for a different file */ string URItoFileName(string URI) { - string::const_iterator I = URI.begin() + URI.find(':') + 1; - for (; I < URI.end() && *I == '/'; I++); - + // Nuke 'sensitive' items + ::URI U(URI); + U.User = string(); + U.Password = string(); + U.Access = ""; + // "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF"; - URI = QuoteString(string(I,URI.end() - I),"\\|{}[]<>\"^~_=!@#$%^&*"); + URI = QuoteString(U,"\\|{}[]<>\"^~_=!@#$%^&*"); string::iterator J = URI.begin(); for (; J != URI.end(); J++) if (*J == '/') @@ -809,17 +812,24 @@ void URI::CopyFrom(string U) /* */ URI::operator string() { - string Res = Access + ':'; + string Res; + + if (Access.empty() == false) + Res = Access + ':'; + if (Host.empty() == false) { - Res += "//"; + if (Access.empty() == false) + Res += "//"; + if (User.empty() == false) { - Res += "//" + User; + Res += User; if (Password.empty() == false) Res += ":" + Password; Res += "@"; } + Res += Host; if (Port != 0) { |