mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-11 01:10:13 +00:00
WebDocument without size is allowed to load.
We load a WebDocument with an unknown size the same way as we load normal photos with FileLocation, that doesn't contain size as well. If the size information from WebDocument and upload.WebFile is inconsistent we still fail to load the file.
This commit is contained in:
parent
12ca6f3819
commit
a7d0473a1a
@ -126,7 +126,6 @@ enum {
|
||||
MaxPhotoCaption = 200,
|
||||
|
||||
MaxMessageSize = 4096,
|
||||
MaxHttpRedirects = 5, // when getting external data/images
|
||||
|
||||
WriteMapTimeout = 1000,
|
||||
SaveDraftTimeout = 1000, // save draft after 1 secs of not changing text
|
||||
|
@ -27,6 +27,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
namespace {
|
||||
|
||||
constexpr auto kCoordPrecision = 8;
|
||||
constexpr auto kMaxHttpRedirects = 5;
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -144,7 +145,7 @@ void LocationManager::onFinished(QNetworkReply *reply) {
|
||||
LocationData *d = i.value();
|
||||
if (serverRedirects.constFind(d) == serverRedirects.cend()) {
|
||||
serverRedirects.insert(d, 1);
|
||||
} else if (++serverRedirects[d] > MaxHttpRedirects) {
|
||||
} else if (++serverRedirects[d] > kMaxHttpRedirects) {
|
||||
DEBUG_LOG(("Network Error: Too many HTTP redirects in onFinished() for image link: %1").arg(loc));
|
||||
return onFailed(reply);
|
||||
}
|
||||
@ -155,7 +156,7 @@ void LocationManager::onFinished(QNetworkReply *reply) {
|
||||
LocationData *d = i.value();
|
||||
if (serverRedirects.constFind(d) == serverRedirects.cend()) {
|
||||
serverRedirects.insert(d, 1);
|
||||
} else if (++serverRedirects[d] > MaxHttpRedirects) {
|
||||
} else if (++serverRedirects[d] > kMaxHttpRedirects) {
|
||||
DEBUG_LOG(("Network Error: Too many HTTP redirects in onFinished() for image link: %1").arg(loc));
|
||||
return onFailed(reply);
|
||||
}
|
||||
|
@ -493,7 +493,9 @@ void mtpFileLoader::webPartLoaded(int offset, const MTPupload_WebFile &result, m
|
||||
return cancel(true);
|
||||
}
|
||||
auto &webFile = result.c_upload_webFile();
|
||||
if (webFile.vsize.v != _size) {
|
||||
if (!_size) {
|
||||
_size = webFile.vsize.v;
|
||||
} else if (webFile.vsize.v != _size) {
|
||||
LOG(("MTP Error: Bad size provided by bot for webDocument: %1, real: %2").arg(_size).arg(webFile.vsize.v));
|
||||
return cancel(true);
|
||||
}
|
||||
@ -780,10 +782,7 @@ public:
|
||||
webFileLoaderPrivate(webFileLoader *loader, const QString &url)
|
||||
: _interface(loader)
|
||||
, _url(url)
|
||||
, _already(0)
|
||||
, _size(0)
|
||||
, _reply(0)
|
||||
, _redirectsLeft(MaxHttpRedirects) {
|
||||
, _redirectsLeft(kMaxHttpRedirects) {
|
||||
}
|
||||
|
||||
QNetworkReply *reply() {
|
||||
@ -830,11 +829,14 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
webFileLoader *_interface;
|
||||
static constexpr auto kMaxHttpRedirects = 5;
|
||||
|
||||
webFileLoader *_interface = nullptr;
|
||||
QUrl _url;
|
||||
qint64 _already, _size;
|
||||
QNetworkReply *_reply;
|
||||
int32 _redirectsLeft;
|
||||
qint64 _already = 0;
|
||||
qint64 _size = 0;
|
||||
QNetworkReply *_reply = nullptr;
|
||||
int32 _redirectsLeft = kMaxHttpRedirects;
|
||||
QByteArray _data;
|
||||
|
||||
friend class WebLoadManager;
|
||||
|
Loading…
Reference in New Issue
Block a user