From: Michael Brown Date: Fri, 13 Feb 2009 16:26:43 +0000 (+0000) Subject: [http] Allow for URI encodings within username and password X-Git-Tag: v0.9.7~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=816a32aaeefc15c36a7d94f08927787d431fe7e7;p=thirdparty%2Fipxe.git [http] Allow for URI encodings within username and password --- diff --git a/src/net/tcp/http.c b/src/net/tcp/http.c index 1052400eb..57487308f 100644 --- a/src/net/tcp/http.c +++ b/src/net/tcp/http.c @@ -407,8 +407,21 @@ static void http_step ( struct process *process ) { /* Construct authorisation, if applicable */ if ( user_pw_len ) { - snprintf ( user_pw, sizeof ( user_pw ), "%s:%s", - user, password ); + char *buf = user_pw; + ssize_t remaining = sizeof ( user_pw ); + size_t len; + + /* URI-decode the username and password */ + len = uri_decode ( user, buf, remaining ); + buf += len; + remaining -= len; + *(remaining--, buf++) = ':'; + len = uri_decode ( password, buf, remaining ); + buf += len; + remaining -= len; + assert ( remaining >= 0 ); + + /* Base64-encode the "user:password" string */ base64_encode ( user_pw, user_pw_base64 ); }