plasma5-workspace/0007-Klipper-Guard-against-broken-data-fetches.patch
Luca Beltrame 06d8e54685 Accepting request 921296 from home:Vogtinator:plasma5.23
- Add patch to fix build with gpsd:
  * 0001-Fix-build-with-gpsd-3.23.1.patch
- Add patch to fix window thumbnails if dmabuf is not supported (kde#428284):
  * 0002-libtaskmanager-Don-t-request-dmabuf-if-not-supported.patch

- Add patches from Plasma/5.23 branch:
  * 0001-SVN_SILENT-made-messages-.desktop-file-always-resolv.patch
  * 0002-shell-panel-Fix-ability-to-type-in-textfield.patch
  * 0003-SVN_SILENT-made-messages-.desktop-file-always-resolv.patch
  * 0004-PipeWire-Make-sure-thumbnails-properly-use-dmabuf-ag.patch
  * 0005-SVN_SILENT-made-messages-.desktop-file-always-resolv.patch
  * 0006-Klipper-Handle-incoming-UTF-8-mime-types.patch
  * 0007-Klipper-Guard-against-broken-data-fetches.patch
  * 0008-pipewire-Properly-compare-pipewire-versions-using-QV.patch
  * 0009-PipeWire-Include-defines-for-older-PipeWire-versions.patch
  * 0010-sddm-theme-fix-default-username-font-size.patch
- Add patch to fix XEmbed context menus (kde#442758)
  * 0011-Revert-xembed-adapt-to-changes-in-KNotifications.patch

OBS-URL: https://build.opensuse.org/request/show/921296
OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5/plasma5-workspace?expand=0&rev=615
2021-09-25 13:06:42 +00:00

51 lines
1.9 KiB
Diff

From 0e8493e24281d393cb08da3d13e55276f4578fd5 Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Fri, 17 Sep 2021 23:44:05 +0100
Subject: [PATCH 07/11] [Klipper] Guard against broken data fetches
QMimeData::data() can fail. Fetching is done on demand. It's also
possible for clients to advertise mimedata they don't really have.
This patch avoids putting those broken entries in klipper's history.
(cherry picked from commit 22ff0818cdd64ec205c084ffb1483d8635b8e5d7)
---
klipper/historyitem.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/klipper/historyitem.cpp b/klipper/historyitem.cpp
index fd0a5ad33..7ee2496f3 100644
--- a/klipper/historyitem.cpp
+++ b/klipper/historyitem.cpp
@@ -30,15 +30,25 @@ HistoryItemPtr HistoryItem::create(const QMimeData *data)
if (data->hasUrls()) {
KUrlMimeData::MetaDataMap metaData;
QList<QUrl> urls = KUrlMimeData::urlsFromMimeData(data, KUrlMimeData::PreferKdeUrls, &metaData);
+ if (urls.isEmpty()) {
+ return HistoryItemPtr();
+ }
QByteArray bytes = data->data(QStringLiteral("application/x-kde-cutselection"));
bool cut = !bytes.isEmpty() && (bytes.at(0) == '1'); // true if 1
return HistoryItemPtr(new HistoryURLItem(urls, metaData, cut));
}
if (data->hasText()) {
+ const QString text = data->text();
+ if (text.isEmpty()) { // reading mime data can fail. Avoid ghost entries
+ return HistoryItemPtr();
+ }
return HistoryItemPtr(new HistoryStringItem(data->text()));
}
if (data->hasImage()) {
- QImage image = qvariant_cast<QImage>(data->imageData());
+ const QImage image = qvariant_cast<QImage>(data->imageData());
+ if (image.isNull()) {
+ return HistoryItemPtr();
+ }
return HistoryItemPtr(new HistoryImageItem(QPixmap::fromImage(image)));
}
--
2.33.0