summaryrefslogtreecommitdiff
path: root/lib/url.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-02-17 18:08:48 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2012-02-20 17:11:21 +0100
commit86f4846c2166ce91b17674d066f8fb3a5a278a8c (patch)
tree37264395cf55716ee036a9c5445708f39a746085 /lib/url.js
parent0cebfc8ddb509fbf5f865bb660b73e96680b3f65 (diff)
downloadandroid-node-v8-86f4846c2166ce91b17674d066f8fb3a5a278a8c.tar.gz
android-node-v8-86f4846c2166ce91b17674d066f8fb3a5a278a8c.tar.bz2
android-node-v8-86f4846c2166ce91b17674d066f8fb3a5a278a8c.zip
url: decode url entities in auth section
Fixes #2736.
Diffstat (limited to 'lib/url.js')
-rw-r--r--lib/url.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/url.js b/lib/url.js
index 4f1c0e0e9c..8608a53fd8 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -135,19 +135,21 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
// URLs are obnoxious.
var atSign = rest.indexOf('@');
if (atSign !== -1) {
+ var auth = rest.slice(0, atSign);
+
// there *may be* an auth
var hasAuth = true;
for (var i = 0, l = nonAuthChars.length; i < l; i++) {
- var index = rest.indexOf(nonAuthChars[i]);
- if (index !== -1 && index < atSign) {
+ if (auth.indexOf(nonAuthChars[i]) !== -1) {
// not a valid auth. Something like http://foo.com/bar@baz/
hasAuth = false;
break;
}
}
+
if (hasAuth) {
// pluck off the auth portion.
- out.auth = rest.substr(0, atSign);
+ out.auth = decodeURIComponent(auth);
rest = rest.substr(atSign + 1);
}
}
@@ -329,11 +331,8 @@ function urlFormat(obj) {
var auth = obj.auth || '';
if (auth) {
- auth = auth.split('@').join('%40');
- for (var i = 0, l = nonAuthChars.length; i < l; i++) {
- var nAC = nonAuthChars[i];
- auth = auth.split(nAC).join(encodeURIComponent(nAC));
- }
+ auth = encodeURIComponent(auth);
+ auth = auth.replace(/%3A/i, ':');
auth += '@';
}