diff --git a/src/handlers/xdgurl.cpp b/src/handlers/xdgurl.cpp
index 143a16b6ce618c5ce95e97c5d9feef1bf6447aeb..fb93f12cef95da6df9c0fa683737f8bbc1ca756d 100644
--- a/src/handlers/xdgurl.cpp
+++ b/src/handlers/xdgurl.cpp
@@ -50,7 +50,7 @@ QJsonObject XdgUrl::_parse()
     }
 
     if (query.hasQueryItem("filename") && !query.queryItemValue("filename").isEmpty()) {
-        meta["filename"] = query.queryItemValue("filename", QUrl::FullyDecoded).split("?").at(0);
+        meta["filename"] = QUrl(query.queryItemValue("filename", QUrl::FullyDecoded)).fileName();
     }
 
     if (!meta["url"].toString().isEmpty() && meta["filename"].toString().isEmpty()) {