X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/cfc6566d5097ef5518e12f5c1e5f15a8f5b182cf..a1f3ac8aba0675321dd46d074af8abcbb10c19fd:/apt-pkg/contrib/strutl.cc diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index d0bc938e4..6c72859d4 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -749,6 +749,10 @@ int StringToBool(const string &Text,int Default) /* This converts a time_t into a string time representation that is year 2000 complient and timezone neutral */ string TimeRFC1123(time_t Date) +{ + return TimeRFC1123(Date, false); +} +string TimeRFC1123(time_t Date, bool const NumericTimezone) { struct tm Conv; if (gmtime_r(&Date, &Conv) == NULL) @@ -757,10 +761,14 @@ string TimeRFC1123(time_t Date) auto const posix = std::locale("C.UTF-8"); std::ostringstream datestr; datestr.imbue(posix); - APT::StringView const fmt("%a, %d %b %Y %H:%M:%S GMT"); + APT::StringView const fmt("%a, %d %b %Y %H:%M:%S"); std::use_facet>(posix).put( std::ostreambuf_iterator(datestr), datestr, ' ', &Conv, fmt.data(), fmt.data() + fmt.size()); + if (NumericTimezone) + datestr << " +0000"; + else + datestr << " GMT"; return datestr.str(); } /*}}}*/ @@ -1631,13 +1639,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) {