summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorEugene V. Lyubimkin <jackyf@1501-debian>2008-10-25 17:03:16 +0300
committerEugene V. Lyubimkin <jackyf@1501-debian>2008-10-25 17:03:16 +0300
commit4805f1cfd795c41db2a3c7fed56c15bb8c350c49 (patch)
treedc1b6aca57f6a3b22a0b8028b747cdb13c12c4e6 /apt-pkg
parent0d7a243df522cad460bc1f94f32c6b7f766cabb1 (diff)
Strip user/password from URL in error message.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/algorithms.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 2e2a976bb..bd59a4749 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -23,6 +23,7 @@
#include <apti18n.h>
#include <sys/types.h>
+#include <regex.h>
#include <cstdlib>
#include <algorithm>
#include <iostream>
@@ -1342,7 +1343,22 @@ bool ListUpdate(pkgAcquireStatus &Stat,
(*I)->Finished();
- _error->Warning(_("Failed to fetch %s %s\n"),(*I)->DescURI().c_str(),
+ // stripping username/password from URI if present
+ string descUri = (*I)->DescURI();
+ regex_t userPassRegex;
+ regcomp(&userPassRegex, "\\://(\\w+)\\:(\\w+)@", REG_EXTENDED);
+ regmatch_t userPassMatch;
+ regexec(&userPassRegex, descUri.c_str(), 1, &userPassMatch, 0);
+ if (userPassMatch.rm_so != -1) // regexp matched
+ {
+ // really stripping
+ size_t stripStart = userPassMatch.rm_so + 3;
+ size_t stripEnd = userPassMatch.rm_eo;
+ descUri = descUri.substr(0, stripStart) +
+ descUri.substr(stripEnd, string::npos);
+ }
+
+ _error->Warning(_("Failed to fetch %s %s\n"), descUri.c_str(),
(*I)->ErrorText.c_str());
if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError)