summaryrefslogtreecommitdiff
path: root/kde-frameworks/kcoreaddons/files/kcoreaddons-5.108.0-kurlmimedata-dont-portal-symlinks.patch
blob: 0d5e6767c46f1fcd6c9f767faa435b63e23ebfa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 2ec1a017b4cd0c56318b38ccd92b523ad21a1a08 Mon Sep 17 00:00:00 2001
From: Harald Sitter <sitter@kde.org>
Date: Thu, 29 Jun 2023 12:43:14 +0200
Subject: [PATCH] kurlmimedata: don't portal symlinks

they are not really supported. from testing it seems that opening
O_NOFOLLOW results in the portal not being able to use the fd so
ultimately we have no way to copy a symlink (instead of the file it
points to)

BUG: 464225


(cherry picked from commit 14e954248e365098e4b98cfd7c76e5ea1defb8a7)
---
 src/lib/io/kurlmimedata.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/lib/io/kurlmimedata.cpp b/src/lib/io/kurlmimedata.cpp
index 6b62232c1..fe18717c6 100644
--- a/src/lib/io/kurlmimedata.cpp
+++ b/src/lib/io/kurlmimedata.cpp
@@ -275,9 +275,17 @@ bool KUrlMimeData::exportUrlsToPortal(QMimeData *mimeData)
                 qWarning() << "kio-fuse is missing";
                 return false;
             }
-        } else if (isLocal && QFileInfo(url.toLocalFile()).isDir()) {
-            // XDG Document Portal doesn't support directories and silently drops them.
-            return false;
+        } else {
+            const QFileInfo info(url.toLocalFile());
+            if (info.isDir()) {
+                // XDG Document Portal doesn't support directories and silently drops them.
+                return false;
+            }
+            if (info.isSymbolicLink()) {
+                // XDG Document Portal also doesn't support symlinks since it doesn't let us open the fd O_NOFOLLOW.
+                // https://github.com/flatpak/xdg-desktop-portal/issues/961#issuecomment-1573646299
+                return false;
+            }
         }
     }
 
-- 
GitLab