diff options
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 34 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 8 |
2 files changed, 28 insertions, 14 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 3175ba4430..0867673593 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -135,17 +135,23 @@ void Config::accept() | |||
135 | proxy.setPort(ui.proxyPort->text().toInt()); | 135 | proxy.setPort(ui.proxyPort->text().toInt()); |
136 | } | 136 | } |
137 | 137 | ||
138 | // QUrl::toEncoded() doesn't encode a colon in the password correctly, | 138 | // Encode the password using base64 before storing it to the configuration |
139 | // which will result in errors during parsing the string. | 139 | // file. |
140 | // QUrl::toPercentEncoding() does work as expected, so build the string to | 140 | // There are two reasons for doing this: |
141 | // store in the configuration file manually. | 141 | // - QUrl::toEncoded() has problems with some characters like the colon and |
142 | QString proxystring = "http://" | 142 | // @. Those are not percent encoded, causing the string getting parsed |
143 | + QString(QUrl::toPercentEncoding(proxy.userName())) + ":" | 143 | // wrongly when reading it back (see FS#12166). |
144 | + QString(QUrl::toPercentEncoding(proxy.password())) + "@" | 144 | // - The password is cleartext in the configuration file. |
145 | + proxy.host() + ":" | 145 | // While using base64 doesn't provide any real security either it's at |
146 | + QString::number(proxy.port()); | 146 | // least better than plaintext. |
147 | RbSettings::setValue(RbSettings::Proxy, proxystring); | 147 | // Since this program is open source any fixed mechanism to obfuscate / |
148 | qDebug() << "[Config] setting proxy to:" << proxy; | 148 | // encrypt the password isn't much help either since anyone interested in |
149 | // the password can look at the sources. The best way would be to | ||
150 | // eventually use host OS functionality to store the password. | ||
151 | QUrl p = proxy; | ||
152 | p.setPassword(proxy.password().toUtf8().toBase64()); | ||
153 | RbSettings::setValue(RbSettings::Proxy, p.toString()); | ||
154 | qDebug() << "[Config] setting proxy to:" << proxy.toString(QUrl::RemovePassword); | ||
149 | // proxy type | 155 | // proxy type |
150 | QString proxyType; | 156 | QString proxyType; |
151 | if(ui.radioNoProxy->isChecked()) proxyType = "none"; | 157 | if(ui.radioNoProxy->isChecked()) proxyType = "none"; |
@@ -239,7 +245,11 @@ void Config::abort() | |||
239 | void Config::setUserSettings() | 245 | void Config::setUserSettings() |
240 | { | 246 | { |
241 | // set proxy | 247 | // set proxy |
242 | proxy.setEncodedUrl(RbSettings::value(RbSettings::Proxy).toByteArray()); | 248 | proxy.setUrl(RbSettings::value(RbSettings::Proxy).toString(), |
249 | QUrl::StrictMode); | ||
250 | // password is base64 encoded in configuration. | ||
251 | QByteArray pw = QByteArray::fromBase64(proxy.password().toUtf8()); | ||
252 | proxy.setPassword(pw); | ||
243 | 253 | ||
244 | if(proxy.port() > 0) | 254 | if(proxy.port() > 0) |
245 | ui.proxyPort->setText(QString("%1").arg(proxy.port())); | 255 | ui.proxyPort->setText(QString("%1").arg(proxy.port())); |
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index c5cdeb1cf7..6ff80c3cc2 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -610,8 +610,12 @@ QUrl RbUtilQt::proxy() | |||
610 | { | 610 | { |
611 | QUrl proxy; | 611 | QUrl proxy; |
612 | QString proxytype = RbSettings::value(RbSettings::ProxyType).toString(); | 612 | QString proxytype = RbSettings::value(RbSettings::ProxyType).toString(); |
613 | if(proxytype == "manual") | 613 | if(proxytype == "manual") { |
614 | proxy.setEncodedUrl(RbSettings::value(RbSettings::Proxy).toByteArray()); | 614 | proxy.setUrl(RbSettings::value(RbSettings::Proxy).toString(), |
615 | QUrl::TolerantMode); | ||
616 | QByteArray pw = QByteArray::fromBase64(proxy.password().toUtf8()); | ||
617 | proxy.setPassword(pw); | ||
618 | } | ||
615 | else if(proxytype == "system") | 619 | else if(proxytype == "system") |
616 | proxy = System::systemProxy(); | 620 | proxy = System::systemProxy(); |
617 | 621 | ||