[file-roller] command-rar: Fix ask password for encrypted RARs
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] command-rar: Fix ask password for encrypted RARs
- Date: Wed, 17 Aug 2022 19:36:25 +0000 (UTC)
commit f2559d78f4b99136bd1a11700d7c9d5dd00d935e
Author: Jake Dane <3689-jakedane users noreply gitlab gnome org>
Date: Sun Aug 14 07:59:35 2022 +0000
command-rar: Fix ask password for encrypted RARs
fr_command_rar_handle_error () searched for certain strings in the
command output to detect the password was wrong or missing. This didn't
work correctly from at least version 5.50 of rar/unrar and made it
impossible to extract files from encrypted RARs or open RARs with an
encrypted header, because file-roller wouldn't ask for a password.
From at least version 5.50 of rar/unrar the commands give exit value 11
when the password was wrong or missing. fr_command_rar_handle_error ()
is changed to check for that exit value and now asks for a password
when that is needed.
Fixes #139.
src/fr-command-rar.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
---
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index 8407f379..d5e16b5f 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -727,28 +727,19 @@ fr_command_rar_handle_error (FrCommand *comm,
if (error->type == FR_ERROR_NONE)
return;
- /* ignore warnings */
- if (error->status <= 1)
+ if (error->status <= 1) {
+ /* ignore warnings */
fr_error_clear_gerror (error);
+ }
+ else if (error->status == 11) {
+ /* handle wrong password */
+ fr_error_take_gerror (error, g_error_new_literal (FR_ERROR, FR_ERROR_ASK_PASSWORD, ""));
+ return;
+ }
for (scan = g_list_last (comm->process->err.raw); scan; scan = scan->prev) {
char *line = scan->data;
- if (strstr (line, "password incorrect") != NULL) {
- fr_error_take_gerror (error, g_error_new_literal (FR_ERROR, FR_ERROR_ASK_PASSWORD,
""));
- break;
- }
-
- if (strstr (line, "password is incorrect") != NULL) {
- fr_error_take_gerror (error, g_error_new_literal (FR_ERROR, FR_ERROR_ASK_PASSWORD,
""));
- break;
- }
-
- if (strstr (line, "wrong password") != NULL) {
- fr_error_take_gerror (error, g_error_new_literal (FR_ERROR, FR_ERROR_ASK_PASSWORD,
""));
- break;
- }
-
if (strncmp (line, "Unexpected end of archive", 25) == 0) {
/* FIXME: handle this type of errors at a higher level when the freeze is over. */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]