Bug 382437 - Regression in kdialog causes wrong file extension
Summary: Regression in kdialog causes wrong file extension
Status: RESOLVED FIXED
Alias: None
Product: kdialog
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords: regression
: 383383 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-07-17 18:24 UTC by Fabian Maurer
Modified: 2018-04-05 08:35 UTC (History)
19 users (show)

See Also:
Latest Commit:
Version Fixed In: KDE Frameworks 5.44
Sentry Crash Report:


Attachments
Don't change extention for application/octet-stream (740 bytes, patch)
2018-01-12 01:45 UTC, Igor Janssen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Maurer 2017-07-17 18:24:13 UTC
Using Arch Linux. When upgrading from kdialog 17.04.2-1 to 17.04.3-2, every download in google chrome gets the file extension ".bin" instead of its original extension.

Bisected to
commit 9dc6258065b23d05411d7b6110029c9134b8c02c
Author: David Faure <faure@kde.org>
Date:   Fri Jun 23 09:23:46 2017 +0200

    Port kdialog from KFileDialog to QFileDialog.
Comment 1 Christoph Feck 2017-07-17 19:19:18 UTC
See also https://bugs.freedesktop.org/show_bug.cgi?id=101667

As far as I know, local changes to the shared-mime-database can be stored in .local/share/mime, so it might be possible to workaround this by using a local configuration.
Comment 2 Fabian Maurer 2017-07-17 20:37:28 UTC
Thanks for the info, it seems useful to address the actual problem then.
Any idea on how to do that workaround?
Comment 3 Christoph Feck 2017-08-13 11:25:13 UTC
*** Bug 383383 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Shark 2017-08-22 02:17:57 UTC
Possible workaround:
In filter field drop-down list is set to Unknown by default and extension is bin. But you can scroll it down and then extension will be set properly.
Comment 5 Patrick Silva 2017-11-03 11:43:14 UTC
still happening with chromium on neon dev unstable.
I get correct file extensions after uncheck "automatically select file exension" below "filter" drop down.
Comment 6 Aleksey Kontsevich 2017-11-04 10:00:47 UTC
Confirm regression exists for me in openSUSE Tumbleweed: bug still exists in latest KDE when downloading file in FF or Chromium. I get .bin extension for all files instead of jpg, mp3, pdf, etc.
Comment 7 Pavel 2017-12-01 06:12:43 UTC
*** This bug has been confirmed by popular vote. ***
Comment 8 Alberto Salvia Novella 2017-12-05 17:16:06 UTC
Also confirmed in Manjaro:
https://forum.manjaro.org/t/chromium-to-download-files-with-the-appropriate-extension/35930

A screen-cast of the bug:
https://youtu.be/jrQgPtAZk-k
Comment 9 Aleksey Kontsevich 2017-12-21 04:11:12 UTC
Another bug here: if I download and save some file to directory named ../C#/ or ../C#/../..  it renamed to C and stored in parent ../C#/ directory.
Comment 10 Alberto Salvia Novella 2017-12-21 18:44:07 UTC
@Aleksey Kontsevich, please:

1. Open a new report about that.
2. Paste its link here.

Thanks ;)
Comment 11 Aleksey Kontsevich 2017-12-21 18:55:04 UTC
(In reply to Alberto Salvia Novella from comment #10)
> @Aleksey Kontsevich, please:
> 
> 1. Open a new report about that.
> 2. Paste its link here.

Related to Bug 388124.
Comment 12 Kai Uwe Broulik 2018-01-07 19:09:29 UTC
Any idea on a remedy here? I've gotten numerous complaints from various people, both skilled and novice, that saving files in their web browser suggests "Unknown *.bin" extension
Comment 14 Denis M. (Phr33d0m) 2018-01-07 23:50:18 UTC
There is a workaround inside kdialog, there's no need to uninstall it. Read the 1st comment I posted some time ago at Bug #383383
Comment 15 Igor Janssen 2018-01-12 01:45:01 UTC
Created attachment 109809 [details]
Don't change extention for application/octet-stream

Another cause of the bug is commit at plasma-integration:
author	Elvis Angelaccio <elvis.angelaccio@kde.org>	2017-05-23 10:48:24 (GMT)
commit	0dafb9403266d6064074250d44b74dc0db946cfb
 /src/platformtheme/kdeplatformfiledialoghelper.cpp
parent	708ff0d0b2905e4c68a9fb22b8a2f439d2f2fb65 (diff)
Make sure we always set a default mime filter in save mode
KFileWidget::setMimeFilter() documentation says a default mime filter
should be set if the dialog is being open in save mode.

Without a default filter, the dialog uses a custom item (created by
concatenating all the mime type filters) as default. This is not useful
because it means an additional click for the user to select a filter that can
actually be useful.

If the initiallySelectedMimeTypeFilter() is empty, we use the first mime
filter as fallback.

-----
Chrome opens kdialog with 2 mime types: application/octet-stream (means any file) and (for example) image/jpeg. But application/octet-stream is associated with *.bin extension. When you choose this mime extention becomes *.bin. That commit does this mime default (it's first).

I suggest to do something as at KFileWidget...
Don't change extention for application/octet-stream
At kio package:

--- a/src/filewidgets/kfilewidget.cpp
+++ b/src/filewidgets/kfilewidget.cpp
@@ -2245,7 +2245,8 @@ void KFileWidgetPrivate::updateAutoSelectExtension()
                 }
             }
 
-            if (!currentExtension.isEmpty() && extensionList.contains(QLatin1String("*.") + currentExtension)) {
+            if ((!currentExtension.isEmpty() && extensionList.contains(QLatin1String("*.") + currentExtension))
+                    || filter == QStringLiteral("application/octet-stream")) {
                 extension = QLatin1Char('.') + currentExtension;
             } else {
                 extension = defaultExtension;
Comment 16 Christoph Feck 2018-01-31 01:40:30 UTC
https://phabricator.kde.org/D10114
Comment 17 David 2018-02-07 09:17:54 UTC
Can confirm the bug is still present in debian sid with plasma 5.11.4, kde applications 17.08, and frameworks 5.42. It also affects other software.
Comment 18 Nate Graham 2018-02-10 17:04:15 UTC
Git commit 0f8c2d7922ca130971ac3a83ed86d8e552171389 by Nathaniel Graham, on behalf of Igor Janssen.
Committed on 10/02/2018 at 16:56.
Pushed by ngraham into branch 'master'.

Fix bug #382437 "Regression in kdialog causes wrong file extension"

Summary:
One cause of the bug is commit at plasma-integration:
0dafb9403266d6064074250d44b74dc0db946cfb
//Make sure we always set a default mime filter in save mode
KFileWidget::setMimeFilter() documentation says a default mime filter
should be set if the dialog is being open in save mode.
Without a default filter, the dialog uses a custom item (created by
concatenating all the mime type filters) as default. This is not useful
because it means an additional click for the user to select a filter that can
actually be useful.
If the initiallySelectedMimeTypeFilter() is empty, we use the first mime
filter as fallback.//

Chrome opens kdialog with 2 mime types: application/octet-stream (means any file) and (for example) image/jpeg. But application/octet-stream is associated with *.bin extension. When you choose this mime extention becomes *.bin. That commit does this mime default (it's first).
This patch blocks changing extention to bin for "application/octet-stream" selected.

Test Plan: Tested with Google  Chrome. Used Open/Save dialogs for files.

Reviewers: #plasma, dfaure

Reviewed By: dfaure

Subscribers: ngraham, aacid, broulik, plasma-devel, #frameworks

Tags: #frameworks, #plasma

Differential Revision: https://phabricator.kde.org/D10114

M  +2    -1    src/filewidgets/kfilewidget.cpp

https://commits.kde.org/kio/0f8c2d7922ca130971ac3a83ed86d8e552171389