[file-roller] rar: fixed error with some password protected files
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] rar: fixed error with some password protected files
- Date: Mon, 11 Nov 2013 20:36:15 +0000 (UTC)
commit 15c65e770ae3e9c5cd005a506eb30c6dff5de7e6
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Nov 11 21:24:59 2013 +0100
rar: fixed error with some password protected files
[bug #711745]
src/fr-command-rar.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index 8eb7d06..7619225 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -117,6 +117,16 @@ Pathname/Comment
*/
+static gboolean
+attribute_field_with_space (char *line)
+{
+ /* sometimes when the archive is encrypted the attributes field is
+ * like this: "* ..A...."
+ * */
+ return ((line[0] != ' ') && (line[1] == ' '));
+}
+
+
static void
parse_name_field (char *line,
FrCommandRar *rar_comm)
@@ -132,7 +142,7 @@ parse_name_field (char *line,
if (rar_comm->rar5)
/* rar-5 output adds trailing spaces to short file names :( */
- name_field = g_strchomp (g_strdup (_g_str_get_last_field (line, 8)));
+ name_field = g_strchomp (g_strdup (_g_str_get_last_field (line, attribute_field_with_space
(line) ? 9 : 8)));
else
name_field = g_strdup (line + 1);
@@ -210,13 +220,15 @@ process_line (char *line,
/* read file info. */
- fields = _g_str_split_line (line, 6);
+ fields = _g_str_split_line (line, attribute_field_with_space (line) ? 7 : 6);
if (rar_comm->rar5) {
- size_field = fields[1];
- ratio_field = fields[3];
- date_field = fields[4];
- time_field = fields[5];
- attr_field = fields[0];
+ int offset = attribute_field_with_space (line) ? 1 : 0;
+
+ size_field = fields[1+offset];
+ ratio_field = fields[3+offset];
+ date_field = fields[4+offset];
+ time_field = fields[5+offset];
+ attr_field = fields[0+offset];
}
else {
size_field = fields[0];
@@ -654,6 +666,11 @@ fr_command_rar_handle_error (FrCommand *comm,
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]