From bb1d0adcd1224c4b9d9bb69c783c001f05cda314 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 15 Oct 2013 14:45:16 +0200 Subject: [PATCH] BUrl: fix handling of @ character * @ is a separator (between user:password and host) only if there are no slashes before it * All slashes in user and password should be urlencoded (as well as any @ and :) * On the other hand, it's possible to have @ as part of an URL path or query. An example is Google Maps. Gets Google Maps working. --- src/kits/network/libnetapi/Url.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/kits/network/libnetapi/Url.cpp b/src/kits/network/libnetapi/Url.cpp index 8c2644256e..898d2f9e43 100644 --- a/src/kits/network/libnetapi/Url.cpp +++ b/src/kits/network/libnetapi/Url.cpp @@ -659,7 +659,14 @@ BUrl::_ExtractAuthority(const BString& urlString, int16* origin) (*origin) += 2; - int16 userInfoEnd = urlString.FindFirst('@', *origin); + int32 userInfoEnd = urlString.FindFirst('@', *origin); + + // if the @ comes after a /, it can't be the delimiter for + // user:pasword@host. Characters /:@ in user and password must be escaped. + // RFC1738, 3.1, Common Internet Scheme Syntax. + int32 nextSlash = urlString.FindFirst('/', *origin); + if(userInfoEnd > nextSlash) + userInfoEnd = -1; // URL contains userinfo field if (userInfoEnd != -1) {