@@ -252,20 +252,16 @@ int Repo::Impl::mirrorFailureCB(void * data, const char * msg, const char * url,
252252/* *
253253* @brief Format user password string
254254*
255- * Returns user and password in user:password form. If quote is True,
256- * special characters in user and password are URL encoded.
255+ * Returns user and password in user:password form.
256+ * Special characters in user and password are URL encoded.
257257*
258258* @param user Username
259259* @param passwd Password
260- * @param encode If quote is True, special characters in user and password are URL encoded.
261260* @return User and password in user:password form
262261*/
263- static std::string formatUserPassString (const std::string & user, const std::string & passwd, bool encode )
262+ static std::string formatUserPassString (const std::string & user, const std::string & passwd)
264263{
265- if (encode)
266- return urlEncode (user) + " :" + urlEncode (passwd);
267- else
268- return user + " :" + passwd;
264+ return urlEncode (user) + " :" + urlEncode (passwd);
269265}
270266
271267Repo::Impl::Impl (Repo & owner, const std::string & id, Type type, std::unique_ptr<ConfigRepo> && conf)
@@ -524,12 +520,8 @@ static void setHandle(LrHandle * h, ConfigT & config, const char * repoId = null
524520 }
525521
526522 // setup username/password if needed
527- auto userpwd = config.username ().getValue ();
528- if (!userpwd.empty ()) {
529- // TODO Use URL encoded form, needs support in librepo
530- userpwd = formatUserPassString (userpwd, config.password ().getValue (), false );
531- handleSetOpt (h, LRO_USERPWD, userpwd.c_str ());
532- }
523+ handleSetOpt (h, LRO_USERNAME, config.username ().getValue ().empty () ? NULL : config.username ().getValue ().c_str ());
524+ handleSetOpt (h, LRO_PASSWORD, config.password ().getValue ().empty () ? NULL : config.password ().getValue ().c_str ());
533525
534526 if (!config.proxy ().empty () && !config.proxy ().getValue ().empty ())
535527 handleSetOpt (h, LRO_PROXY, config.proxy ().getValue ().c_str ());
@@ -548,7 +540,7 @@ static void setHandle(LrHandle * h, ConfigT & config, const char * repoId = null
548540 else
549541 throw RepoError (_ (" 'proxy_username' is set but not 'proxy_password'" ));
550542 }
551- userpwd = formatUserPassString (userpwd, config.proxy_password ().getValue (), true );
543+ userpwd = formatUserPassString (userpwd, config.proxy_password ().getValue ());
552544 handleSetOpt (h, LRO_PROXYUSERPWD, userpwd.c_str ());
553545 }
554546 }
0 commit comments