Author: colossus
Date: 2006-08-01 10:41:45 +0000 (Tue, 01 Aug 2006)
New Revision: 22603

Modified:
   xarchiver/trunk/src/callbacks.c
   xarchiver/trunk/src/callbacks.h
   xarchiver/trunk/src/extract_dialog.c
   xarchiver/trunk/src/main.c
Log:
Fixed bug when opening archive whose filename contains with [ or ] introduced 
with the previous revision. Thanks to the official 
Xarchiver bug-hunter: baze.


Modified: xarchiver/trunk/src/callbacks.c
===================================================================
--- xarchiver/trunk/src/callbacks.c     2006-08-01 10:22:30 UTC (rev 22602)
+++ xarchiver/trunk/src/callbacks.c     2006-08-01 10:41:45 UTC (rev 22603)
@@ -242,7 +242,7 @@
        xa_set_button_state (1,1,1,0,0 );
        archive->path = g_strdup (path);
        g_free (path);
-    archive->escaped_path = EscapeBadChars (archive->path);
+    archive->escaped_path = EscapeBadChars (archive->path , 0);
     EmptyTextBuffer();
     archive->has_passwd = FALSE;
     gtk_widget_set_sensitive ( iso_info , FALSE );
@@ -300,7 +300,7 @@
        archive = xa_init_archive_structure(archive);
        archive->path = g_strdup (path);
        g_free (path);
-       archive->escaped_path = EscapeBadChars ( archive->path );
+       archive->escaped_path = EscapeBadChars ( archive->path , 0 );
     
        OffDeleteandViewButtons();
     gtk_widget_set_sensitive ( iso_info , FALSE );
@@ -1165,7 +1165,7 @@
        else
        {
                gtk_tree_model_get (model, &iter, 0, &dummy_name, -1);
-               dir = EscapeBadChars ( dummy_name );
+               dir = EscapeBadChars ( dummy_name , 1 );
                names = g_string_new (" ");
                g_string_append ( names , dir );
 
@@ -1443,7 +1443,7 @@
     }
 }
 
-gchar *EscapeBadChars ( gchar *string )
+gchar *EscapeBadChars ( gchar *string , gboolean doublesquare)
 {
        char *q;
        char *escaped;
@@ -1452,13 +1452,13 @@
 
        while (*p != '\000')
        {
-               if (is_escaped_char(*p))
-                       {
+        if (is_escaped_char(*p))
+               {
+                       escapechars++;
+                       if ( doublesquare && (*p == '[' || *p == ']') )
                                escapechars++;
-                               if (*p == '[' || *p == ']')
-                                       escapechars++;
-                       }
-               p++;
+               }
+               p++;
     }
 
        if (!escapechars)
@@ -1472,7 +1472,7 @@
        {
         if (is_escaped_char(*p))
                {
-                       if (*p == '[' || *p == ']')
+                       if ( doublesquare && (*p == '[' || *p == ']') )
                                *q++ = '\\';
                        *q++ = '\\';
                }
@@ -1514,7 +1514,7 @@
 
 void ConcatenateFileNames2 (gchar *filename , GString *data)
 {
-       gchar *esc_filename = EscapeBadChars ( filename );
+       gchar *esc_filename = EscapeBadChars ( filename , 1 );
        g_string_prepend (data, esc_filename);
        g_string_prepend_c (data, ' ');
        g_free (esc_filename);
@@ -1696,7 +1696,7 @@
     local_path = (gchar *) g_malloc ( x + 1);
     strncpy ( local_path, path, x );
     local_path [x] = '\000';
-    local_escaped_path = EscapeBadChars ( local_path );
+    local_escaped_path = EscapeBadChars ( local_path , 1);
     g_free (local_path);
     return local_escaped_path;
 }

Modified: xarchiver/trunk/src/callbacks.h
===================================================================
--- xarchiver/trunk/src/callbacks.h     2006-08-01 10:22:30 UTC (rev 22602)
+++ xarchiver/trunk/src/callbacks.h     2006-08-01 10:41:45 UTC (rev 22603)
@@ -120,7 +120,7 @@
 void OffTooltipPadlock();
 void Update_StatusBar (gchar *msg);
 void xa_watch_child ( GPid pid, gint status, gpointer data);
-gchar *EscapeBadChars ( gchar *path );
+gchar *EscapeBadChars ( gchar *string , gboolean doublesquare);
 gchar *StripPathFromFilename ( gchar *name, gchar *pattern );
 gchar *JoinPathArchiveName ( const gchar * , gchar * );
 char *Show_File_Dialog (int dummy , gpointer title);

Modified: xarchiver/trunk/src/extract_dialog.c
===================================================================
--- xarchiver/trunk/src/extract_dialog.c        2006-08-01 10:22:30 UTC (rev 
22602)
+++ xarchiver/trunk/src/extract_dialog.c        2006-08-01 10:41:45 UTC (rev 
22603)
@@ -325,7 +325,7 @@
 
                        case GTK_RESPONSE_OK:
                        destination_path = g_strdup (gtk_entry_get_text ( 
GTK_ENTRY (dialog_data->destination_path_entry) ));
-                       extract_path = EscapeBadChars ( destination_path );
+                       extract_path = EscapeBadChars ( destination_path , 1 );
 
                        if ( strlen ( extract_path ) == 0 )
                        {

Modified: xarchiver/trunk/src/main.c
===================================================================
--- xarchiver/trunk/src/main.c  2006-08-01 10:22:30 UTC (rev 22602)
+++ xarchiver/trunk/src/main.c  2006-08-01 10:41:45 UTC (rev 22603)
@@ -102,7 +102,7 @@
                                                GString *string = g_string_new 
( "" );
                                                archive->full_path = 1;
                                                archive->overwrite = 1;
-                                               gchar *escaped_path = 
EscapeBadChars (extract_path);
+                                               gchar *escaped_path = 
EscapeBadChars (extract_path , 1);
                                                cli_command = 
xa_extract_single_files ( archive , string, escaped_path );
                                                g_free (escaped_path);
                                                if ( cli_command != NULL )
@@ -384,7 +384,7 @@
 {
        archive = xa_init_archive_structure (archive);
        archive->path = g_strdup (filename);
-       archive->escaped_path = EscapeBadChars(filename);
+       archive->escaped_path = EscapeBadChars(filename , 0);
        archive->type = DetectArchiveType ( archive->path );
        if (archive->type == -2)
                return NULL;

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to