summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2014-07-11 13:03:50 +0400
committerinfirit <[email protected]>2014-09-25 13:27:48 +0200
commit7c8f5f3d73bada32f27625a6939456977ff0757e (patch)
tree5b7d6a3dea069db959d9d556c7c9f494c8efd61f
parentc6dbb4eb3d52f5d01ca1276f99b3e4926c07e3af (diff)
downloadengrampa-7c8f5f3d73bada32f27625a6939456977ff0757e.tar.bz2
engrampa-7c8f5f3d73bada32f27625a6939456977ff0757e.tar.xz
Fix possible errors with some password protected files
-rw-r--r--src/fr-command-rar.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index 631d58a..e9b45dd 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -123,6 +123,15 @@ 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)
@@ -138,7 +147,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 (get_last_field (line, 8)));
+ name_field = g_strchomp (g_strdup (get_last_field (line, attribute_field_with_space (line) ? 9 : 8)));
else
name_field = g_strdup (line + 1);
@@ -216,13 +225,15 @@ process_line (char *line,
/* read file info. */
- fields = split_line (line, 6);
+ fields = 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];
@@ -759,6 +770,11 @@ fr_command_rar_handle_error (FrCommand *comm,
break;
}
+ if (strstr (line, "password is incorrect") != NULL) {
+ error->type = FR_PROC_ERROR_ASK_PASSWORD;
+ break;
+ }
+
if (strstr (line, "wrong password") != NULL)
{
error->type = FR_PROC_ERROR_ASK_PASSWORD;