forked from len0rd/rockbox
Rockbox Utility: fix proxy password getting lost (FS#12166).
The proxy settings are stored as string representation in the configuration file. If username / password contains characters used as separators parsing the string again will cause wrong results. Percent-encode them before storing, and parse it as percent-encoded string when reading it back. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30071 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
dfd4183a7d
commit
a3875d7dfe
2 changed files with 16 additions and 5 deletions
|
|
@ -121,7 +121,16 @@ void Config::accept()
|
|||
proxy.setPort(ui.proxyPort->text().toInt());
|
||||
}
|
||||
|
||||
RbSettings::setValue(RbSettings::Proxy, proxy.toString());
|
||||
// QUrl::toEncoded() doesn't encode a colon in the password correctly,
|
||||
// which will result in errors during parsing the string.
|
||||
// QUrl::toPercentEncoding() does work as expected, so build the string to
|
||||
// store in the configuration file manually.
|
||||
QString proxystring = "http://"
|
||||
+ QString(QUrl::toPercentEncoding(proxy.userName())) + ":"
|
||||
+ QString(QUrl::toPercentEncoding(proxy.password())) + "@"
|
||||
+ proxy.host() + ":"
|
||||
+ QString::number(proxy.port());
|
||||
RbSettings::setValue(RbSettings::Proxy, proxystring);
|
||||
qDebug() << "[Config] setting proxy to:" << proxy;
|
||||
// proxy type
|
||||
QString proxyType;
|
||||
|
|
@ -218,7 +227,7 @@ void Config::abort()
|
|||
void Config::setUserSettings()
|
||||
{
|
||||
// set proxy
|
||||
proxy = RbSettings::value(RbSettings::Proxy).toString();
|
||||
proxy.setEncodedUrl(RbSettings::value(RbSettings::Proxy).toByteArray());
|
||||
|
||||
if(proxy.port() > 0)
|
||||
ui.proxyPort->setText(QString("%1").arg(proxy.port()));
|
||||
|
|
|
|||
|
|
@ -1240,11 +1240,13 @@ void RbUtilQt::updateInfo()
|
|||
|
||||
QUrl RbUtilQt::proxy()
|
||||
{
|
||||
QUrl proxy;
|
||||
if(RbSettings::value(RbSettings::ProxyType) == "manual")
|
||||
return QUrl(RbSettings::value(RbSettings::Proxy).toString());
|
||||
proxy.setEncodedUrl(RbSettings::value(RbSettings::Proxy).toByteArray());
|
||||
else if(RbSettings::value(RbSettings::ProxyType) == "system")
|
||||
return System::systemProxy();
|
||||
return QUrl("");
|
||||
proxy = System::systemProxy();
|
||||
qDebug() << proxy.userName() << proxy.password() << proxy.host() << proxy.port();
|
||||
return proxy;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue