Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: net/http/http_network_transaction.cc

Issue 164504: Unescape username/passwords obtained from URLs before using them for HTTP aut... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/http/http_network_transaction.cc
===================================================================
--- net/http/http_network_transaction.cc (revision 23194)
+++ net/http/http_network_transaction.cc (working copy)
@@ -1667,11 +1667,10 @@
auth_identity_[target].source == HttpAuth::IDENT_SRC_NONE) {
auth_identity_[target].source = HttpAuth::IDENT_SRC_URL;
auth_identity_[target].invalid = false;
- // TODO(wtc) It may be necessary to unescape the username and password
wtc 2009/08/13 21:37:36 I wrote this TODO(wtc) based on what Darin told me
- // after extracting them from the URL. We should be careful about
- // embedded nulls in that case.
- auth_identity_[target].username = ASCIIToWide(request_->url.username());
- auth_identity_[target].password = ASCIIToWide(request_->url.password());
+ // Extract the username:password from the URL.
+ GetIdentifyFromUrl(request_->url,
+ &auth_identity_[target].username,
+ &auth_identity_[target].password);
// TODO(eroman): If the password is blank, should we also try combining
// with a password from the cache?
return true;
@@ -1708,6 +1707,15 @@
return false;
}
+// static
+void HttpNetworkTransaction::GetIdentifyFromUrl(const GURL& url,
+ std::wstring* username,
+ std::wstring* password) {
+ UnescapeRule::Type flags = UnescapeRule::SPACES;
+ *username = UnescapeAndDecodeUTF8URLComponent(url.username(), flags);
brettw 2009/08/13 20:03:34 Just making sure you're sure you know what you wan
eroman 2009/08/13 20:35:36 right, this should be kosher. username/password a
+ *password = UnescapeAndDecodeUTF8URLComponent(url.password(), flags);
+}
+
std::string HttpNetworkTransaction::AuthChallengeLogMessage() const {
std::string msg;
std::string header_val;

Powered by Google App Engine
This is Rietveld 408576698