mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/telegramdesktop/tdesktop
synced 2026-09-20 08:03:45 +08:00
Anchor SmartGlocal tokenization URLs to hosts
This commit is contained in:
@@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "smartglocal/smartglocal_api_client.h"
|
||||
|
||||
#include "base/basic_types.h"
|
||||
#include "base/debug_log.h"
|
||||
#include "smartglocal/smartglocal_error.h"
|
||||
#include "smartglocal/smartglocal_token.h"
|
||||
|
||||
@@ -45,10 +47,26 @@ namespace {
|
||||
}
|
||||
|
||||
[[nodiscard]] QString ComputeApiUrl(PaymentConfiguration configuration) {
|
||||
const auto url = configuration.tokenizeUrl;
|
||||
if (url.startsWith("https://")
|
||||
&& url.endsWith(".smart-glocal.com/cds/v1/tokenize/card")) {
|
||||
return url;
|
||||
const auto url = QUrl(configuration.tokenizeUrl, QUrl::StrictMode);
|
||||
const auto host = url.host();
|
||||
const auto hostSuffix = u".smart-glocal.com"_q;
|
||||
const auto encoded = url.toString(QUrl::FullyEncoded);
|
||||
if (url.isValid()
|
||||
&& url.scheme() == u"https"_q
|
||||
&& host.size() > hostSuffix.size()
|
||||
&& host.endsWith(hostSuffix)
|
||||
&& url.authority(QUrl::FullyEncoded)
|
||||
== url.host(QUrl::FullyEncoded)
|
||||
&& url.path(QUrl::FullyEncoded)
|
||||
== u"/cds/v1/tokenize/card"_q
|
||||
&& !url.hasQuery()
|
||||
&& !url.hasFragment()
|
||||
&& encoded == configuration.tokenizeUrl) {
|
||||
return encoded;
|
||||
}
|
||||
if (!configuration.tokenizeUrl.isEmpty()) {
|
||||
LOG(("Payments Error: Discarding invalid tokenize_url: %1"
|
||||
).arg(configuration.tokenizeUrl));
|
||||
}
|
||||
return QString("https://%1/%2")
|
||||
.arg(APIURLBase(configuration.isTest))
|
||||
|
||||
Reference in New Issue
Block a user