Bug 486289

Summary: 7z encryption detection logic is inefficient and silly
Product: [Applications] krusader Reporter: Pedro V <voidpointertonull+bugskdeorg>
Component: krarcAssignee: Krusader Bugs Distribution List <krusader-bugs-null>
Status: REPORTED ---    
Severity: normal CC: krusader-bugs-null
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

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.