diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-08-01 21:45:29 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2016-10-05 21:53:37 +0200 |
commit | e5f2e875e53cf03112dda0ac72ab252ca9b2b377 (patch) | |
tree | 8e43a6c85d330cfb685a941abafdff9810461b4c /apt-pkg | |
parent | 6c36aa231b8dcde3b4698157a1ed1e7e4054a0ea (diff) |
allow user@host (aka: no password) in URI parsing
If the URI had no password the username was ignored
(cherry picked from commit a1f3ac8aba0675321dd46d074af8abcbb10c19fd)
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 1a7445694..ebde6b20d 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1559,13 +1559,15 @@ void URI::CopyFrom(const string &U) I = FirstColon + 1; if (I > SingleSlash) I = SingleSlash; - for (; I < SingleSlash && *I != ':'; ++I); - string::const_iterator SecondColon = I; - - // Search for the @ after the colon - for (; I < SingleSlash && *I != '@'; ++I); - string::const_iterator At = I; - + + // Search for the @ separating user:pass from host + auto const RevAt = std::find( + std::string::const_reverse_iterator(SingleSlash), + std::string::const_reverse_iterator(I), '@'); + string::const_iterator const At = RevAt.base() == I ? SingleSlash : std::prev(RevAt.base()); + // and then look for the colon between user and pass + string::const_iterator const SecondColon = std::find(I, At, ':'); + // Now write the host and user/pass if (At == SingleSlash) { |