Bug#425150: patch update for #425150

2008-10-26 Thread Eugene V. Lyubimkin
Thanks for Luca Bruno, patch is now smaller, easier to understand.

Attached new version of patch.

-- 
Eugene V. Lyubimkin aka JackYF, Ukrainian C++ developer.
=== modified file 'apt-pkg/algorithms.cc'
--- apt-pkg/algorithms.cc	2008-10-03 18:15:06 +
+++ apt-pkg/algorithms.cc	2008-10-26 11:40:22 +
@@ -1342,7 +1342,12 @@
 
   (*I)->Finished();
 
-  _error->Warning(_("Failed to fetch %s  %s\n"),(*I)->DescURI().c_str(),
+	  ::URI uri((*I)->DescURI());
+	  uri.User.clear();
+	  uri.Password.clear();
+	  string descUri = string(uri);
+
+  _error->Warning(_("Failed to fetch %s  %s\n"), descUri.c_str(),
 	  (*I)->ErrorText.c_str());
 
   if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) 



signature.asc
Description: OpenPGP digital signature


Bug#425150: patch

2008-10-26 Thread Eugene V. Lyubimkin
package apt
tags +patch
thanks

Wrote the patch, attached it.

-- 
Eugene V. Lyubimkin aka JackYF, Ukrainian C++ developer.
=== modified file 'apt-pkg/algorithms.cc'
--- apt-pkg/algorithms.cc	2008-10-03 18:15:06 +
+++ apt-pkg/algorithms.cc	2008-10-25 19:48:38 +
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1342,7 +1343,23 @@
 
   (*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;
+	  int regMatchResult = regexec(&userPassRegex, descUri.c_str(), 1, &userPassMatch, 0);
+	  if (regMatchResult == 0 && 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);
+  }
+  regfree(&userPassRegex);
+
+  _error->Warning(_("Failed to fetch %s  %s\n"), descUri.c_str(),
 	  (*I)->ErrorText.c_str());
 
   if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) 



signature.asc
Description: OpenPGP digital signature