summaryrefslogtreecommitdiffstats
path: root/netwerk/base/nsStandardURL.cpp
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-15 08:09:17 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-15 08:09:17 +0200
commitf138ec95d9d2c9faba019e52467beeed2a73b4f5 (patch)
treeb7e48dbe0baaae42a3a059343fcb277424c482ba /netwerk/base/nsStandardURL.cpp
parentae14556114dcae29f679db7c15f0bc9b707bb89a (diff)
downloadUXP-f138ec95d9d2c9faba019e52467beeed2a73b4f5.tar
UXP-f138ec95d9d2c9faba019e52467beeed2a73b4f5.tar.gz
UXP-f138ec95d9d2c9faba019e52467beeed2a73b4f5.tar.lz
UXP-f138ec95d9d2c9faba019e52467beeed2a73b4f5.tar.xz
UXP-f138ec95d9d2c9faba019e52467beeed2a73b4f5.zip
moebius#131: URL parser - stop preserving empty passwords
https://github.com/MoonchildProductions/moebius/issues/131
Diffstat (limited to 'netwerk/base/nsStandardURL.cpp')
-rw-r--r--netwerk/base/nsStandardURL.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp
index 983e938ca..21c4cf7fd 100644
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -781,11 +781,13 @@ nsStandardURL::BuildNormalizedSpec(const char *spec)
i = AppendSegmentToBuf(buf, i, spec, username, mUsername,
&encUsername, useEncUsername, &diff);
ShiftFromPassword(diff);
- if (password.mLen >= 0) {
+ if (password.mLen > 0) {
buf[i++] = ':';
i = AppendSegmentToBuf(buf, i, spec, password, mPassword,
&encPassword, useEncPassword, &diff);
ShiftFromHost(diff);
+ } else {
+ mPassword.mLen = -1;
}
buf[i++] = '@';
}
@@ -1621,7 +1623,7 @@ nsStandardURL::SetUserPass(const nsACString &input)
usernameLen),
esc_Username | esc_AlwaysCopy,
buf, ignoredOut);
- if (passwordLen >= 0) {
+ if (passwordLen > 0) {
buf.Append(':');
passwordLen = encoder.EncodeSegmentCount(userpass.get(),
URLSegment(passwordPos,
@@ -1629,6 +1631,8 @@ nsStandardURL::SetUserPass(const nsACString &input)
esc_Password |
esc_AlwaysCopy, buf,
ignoredOut);
+ } else {
+ passwordLen = -1;
}
if (mUsername.mLen < 0)
buf.Append('@');
@@ -1659,8 +1663,10 @@ nsStandardURL::SetUserPass(const nsACString &input)
// update positions and lengths
mUsername.mLen = usernameLen;
mPassword.mLen = passwordLen;
- if (passwordLen)
+ if (passwordLen > 0) {
mPassword.mPos = mUsername.mPos + mUsername.mLen + 1;
+ }
+
return NS_OK;
}