From fde769e0b94112072899ae3b63b55bfa11b304ba Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Tue, 7 Mar 2017 20:52:14 +0300
Subject: [PATCH] Don't use WebDocument size field.

WebDocument size field is not a reliable information,
it can be > 0 and != upload.WebFile size field, so just ignore it
and load all WebDocument files as files with unknown size.
---
 Telegram/SourceFiles/history/history_media_types.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp
index ae560f86a..236409417 100644
--- a/Telegram/SourceFiles/history/history_media_types.cpp
+++ b/Telegram/SourceFiles/history/history_media_types.cpp
@@ -3474,7 +3474,10 @@ void HistoryInvoice::fillFromData(const MTPDmessageMediaInvoice &data) {
 			auto mediumsize = shrinkToKeepAspect(imageSize.width(), imageSize.height(), 320, 320);
 			auto medium = ImagePtr(mediumsize.width(), mediumsize.height());
 
-			auto full = ImagePtr(WebFileImageLocation(imageSize.width(), imageSize.height(), doc.vdc_id.v, doc.vurl.v, doc.vaccess_hash.v), doc.vsize.v);
+			// We don't use size from WebDocument, because it is not reliable.
+			// It can be > 0 and different from the real size that we get in upload.WebFile result.
+			auto filesize = 0; // doc.vsize.v;
+			auto full = ImagePtr(WebFileImageLocation(imageSize.width(), imageSize.height(), doc.vdc_id.v, doc.vurl.v, doc.vaccess_hash.v), filesize);
 			auto photoId = rand_value<PhotoId>();
 			auto photo = App::photoSet(photoId, 0, 0, unixtime(), thumb, medium, full);