|
|
|
|
@ -59,12 +59,16 @@ AvatarCache::Result AvatarCache::readObject(const QString& path, const QString&
|
|
|
|
|
!mf_avatar_file_valid(r.preview.toLatin1().constData()) || !r.preview.endsWith(".webp") || |
|
|
|
|
!r.size.isValid() || qint64(r.size.width()) * r.size.height() > 16 * 1024 * 1024 || |
|
|
|
|
r.originalBytes < 1 || r.originalBytes > OriginalMaxBytes || r.previewBytes < 1 || r.previewBytes > MaxBytes || |
|
|
|
|
!r.crop.isValid() || !QRectF(0, 0, 1, 1).contains(r.crop) || qAbs(pixelW - pixelH) > 2) result.error = "invalid avatar manifest"; |
|
|
|
|
!r.crop.isValid() || !QRectF(0, 0, 1, 1).contains(r.crop) || qAbs(pixelW - pixelH) > 2) { |
|
|
|
|
result.error = "invalid avatar manifest"; r = {}; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
QBuffer buffer; buffer.setData(bytes); buffer.open(QIODevice::ReadOnly); |
|
|
|
|
QImageReader reader(&buffer); reader.setAutoTransform(true); const QSize size = reader.size(); |
|
|
|
|
if (!size.isValid() || qint64(size.width()) * size.height() > 16 * 1024 * 1024 || |
|
|
|
|
(reader.format() != "png" && reader.format() != "jpeg" && reader.format() != "webp")) { |
|
|
|
|
(reader.format() != "png" && reader.format() != "jpeg" && reader.format() != "webp") || |
|
|
|
|
(name.endsWith(".webp") && reader.format() != "webp") || (name.endsWith(".png") && reader.format() != "png") || |
|
|
|
|
(name.endsWith(".jpg") && reader.format() != "jpeg")) { |
|
|
|
|
result.error = "invalid image format/dimensions"; return result; |
|
|
|
|
} |
|
|
|
|
if (qMax(size.width(), size.height()) > 2048) reader.setScaledSize(size.scaled(2048, 2048, Qt::KeepAspectRatio)); |
|
|
|
|
|