Identify the "application/vnd.rar" MIME type in order to allow some operations
ClosedPublic

Authored by asensi on Aug 26 2019, 9:23 PM.

Details

Summary

In order to solve Users are not able to browse rar files using Return (although it works for 7z, zip files, etc.), the Internet Media Type "application/vnd.rar" is recognized in KrArcBaseManager::getShortTypeFromMime(const QString &mime).

ADDITIONAL INFORMATION

In https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types the type of rar files is "application/x-rar-compressed", but in the aforementioned page it's also declared that

IANA is the official registry of MIME media types and maintains a [list of all the official MIME types](http://www.iana.org/assignments/media-types/media-types.xhtml)

and precisely in that place what it's stated is "application/vnd.rar", with a link to

https://www.iana.org/assignments/media-types/application/vnd.rar

where it's written

  1. Deprecated alias names for this type: application/x-rar-compressed

Note: "application/vnd.rar" is already used in Krusader, in KrServices::generateKrarcArchiveMimetypes().

The text "application/x-rar;application/x-rar-compressed;application/vnd.rar" can be searched in https://github.com/lxde/libfm/blob/master/data/archivers.list

In Kubuntu 18.04 I executed:

$ xdg-mime query default application/x-rar
org.kde.ark.desktop
$ xdg-mime query default application/x-rar-compressed
org.kde.ark.desktop
$ xdg-mime query default application/vnd.rar
org.kde.ark.desktop
$ xdg-mime query default application/vnd.JUST_TO_CHECK_THAT_IT_CAN_FAIL; echo $?
4

Several people had a similar problem when using other programs (https://bbs.archlinux.org/viewtopic.php?pid=1748314#p1748314 , https://github.com/webmin/webmin/issues/702#issue-276713752).

Test Plan

Browse several compressed files (rar, zip, 7z, etc.) using:

  • the return key,
  • the right arrow key.

Diff Detail

Repository
R167 Krusader
Lint
Lint Skipped
Unit
Unit Tests Skipped
asensi requested review of this revision.Aug 26 2019, 9:23 PM
asensi created this revision.

+1 according to shared-mime-info the mime type is indeed application/vnd.rar

nhiga added a subscriber: nhiga.EditedAug 27 2019, 11:55 AM

Should we also add application/vnd.rar to krArc/krarc.protocol?

diff --git a/krArc/krarc.protocol b/krArc/krarc.protocol
index 345f103..b49553b 100644
--- a/krArc/krarc.protocol
+++ b/krArc/krarc.protocol
@@ -1,7 +1,7 @@
 [Protocol]
 exec=kio_krarc
 protocol=krarc
-archiveMimetype=application/x-7z,application/x-7z-compressed,application/x-ace,application/x-ace-compressed,application/x-arj,application/x-arj-compressed,application/x-cpio,application/x-lha,application/x-lha-compressed,application/x-rar,application/x-rar-compressed,application/zip,application/x-zip,application/x-zip-compressed
+archiveMimetype=application/x-7z,application/x-7z-compressed,application/x-ace,application/x-ace-compressed,application/x-arj,application/x-arj-compressed,application/x-cpio,application/x-lha,application/x-lha-compressed,application/x-rar,application/x-rar-compressed,application/vnd.rar,application/zip,application/x-zip,application/x-zip-compressed
 input=filesystem
 output=filesystem
 listing=Name,Type,Size,Date,Access,Owner,Group,Link
diff --git a/krArc/krarcbasemanager.cpp b/krArc/krarcbasemanager.cpp
index 5f5f4b8..06cc048 100644
--- a/krArc/krarcbasemanager.cpp
+++ b/krArc/krarcbasemanager.cpp
@@ -212,7 +212,7 @@ QString KrArcBaseManager::getShortTypeFromMime(const QString &mime)
         return "7z";
 
     // If it's a rar file but its mimetype isn't "application/x-rar"
-    if (mime == "application/x-rar-compressed")
+    if ((mime == "application/x-rar-compressed") || (mime == "application/vnd.rar"))
         return "rar";
 
     // The short type that will be returned

Should we also add application/vnd.rar to krArc/krarc.protocol?

Just in case, I incorporated it to the proposal, and two reminders were added. Thanks, N. Higa!

asensi updated this revision to Diff 64776.Aug 27 2019, 9:13 PM

"application/vnd.rar" was incorporated to krArc/krarc.protocol, as suggested by N. Higa. Two reminders were also added.

gengisdave accepted this revision as: gengisdave.Sep 12 2019, 12:25 PM
gengisdave added a subscriber: gengisdave.

The patch works fine, although it requires KIO 5.62 or a reverse patch

This revision is now accepted and ready to land.Sep 12 2019, 12:25 PM

Note: For the tests that I performed under Kubuntu 18.04, executing dpkg -l showed:
kio 5.44.0-0ubuntu1 amd64 Resource and network access abstraction

Thanks, Kai Uwe Broulik, N. Higa, and Davide!

This revision was automatically updated to reflect the committed changes.