Bug 486289 - 7z encryption detection logic is inefficient and silly
Summary: 7z encryption detection logic is inefficient and silly
Status: REPORTED
Alias: None
Product: krusader
Classification: Applications
Component: krarc (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krusader Bugs Distribution List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-29 11:38 UTC by Pedro V
Modified: 2024-04-29 11:38 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro V 2024-04-29 11:38:44 UTC
I'll keep the performance issue mostly to Bug #457906 , but the explanation is a useful setup here too.

`getType` in app/Archive/krarchandler.h has a sneaky `bool check7zEncrypted = true` which appears to be left at the default value everywhere. This leads to `kio_krarcProtocol::checkIf7zIsEncrypted` and therefore `kio_krarcProtocol::check7zOutputForPassword` getting executed not even just once, but apparently several times every time the archive or a directory in it is entered. As the external 7z tool is executed by `checkIf7zIsEncrypted` to get a full file list, the performance issue is quite obvious.

The explained check is what's leading to the "silly" part which can be considered broken in some cases. I found this whole issue because Krusader was persistently asking for a password, multiple times every time an archive or a directory in it was opened, so between the performance issues and the dialog popups, it was a chore to do anything.
Figured out the hard way that my non-encrypted archive was triggering the `line.contains("password") && line.contains("enter")` check in `check7zOutputForPassword`, making Krusader believe that it's encrypted. Problem is that a file in the archive could be called `enter_password.html`, and Krusader would be fooled as "enter" and "password" would be matched on the same line in the output of 7z, leading to the password dialog torture.

7z handling in general isn't exactly great anywhere, but surprised to see that Krusader makes the matter significantly worse. Ark doesn't have this oddity.