[Pkg-mc-commits] r73 - in trunk/debian: . patches

winnie at alioth.debian.org winnie at alioth.debian.org
Wed Feb 27 00:33:45 UTC 2008


Author: winnie
Date: 2008-02-27 00:33:43 +0000 (Wed, 27 Feb 2008)
New Revision: 73

Added:
   trunk/debian/patches/33_escaping.patch
Modified:
   trunk/debian/changelog
Log:
Add patch for two bugs


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-02-26 23:40:31 UTC (rev 72)
+++ trunk/debian/changelog	2008-02-27 00:33:43 UTC (rev 73)
@@ -3,8 +3,9 @@
   * revert patch to make scp work again.
   * show again hostname in xterm title.
     + added as 32_show_hostname.patch (and removed from propsed-patches)
+  * Added patch for escaping and unescaping foldernames (Closes: #326047, #458403)
 
- -- Patrick Winnertz <winnie at debian.org>  Tue, 26 Feb 2008 23:48:38 +0100
+ -- Patrick Winnertz <winnie at debian.org>  Wed, 27 Feb 2008 01:28:12 +0100
 
 mc (1:4.6.2~pre1-4) experimental; urgency=low
 

Added: trunk/debian/patches/33_escaping.patch
===================================================================
--- trunk/debian/patches/33_escaping.patch	                        (rev 0)
+++ trunk/debian/patches/33_escaping.patch	2008-02-27 00:33:43 UTC (rev 73)
@@ -0,0 +1,114 @@
+diff -Nurwd mc-4.6.2~pre1.orig/src/command.c mc-4.6.2~pre1/src/command.c
+--- mc-4.6.2~pre1.orig/src/command.c	2008-02-27 01:21:56.000000000 +0100
++++ mc-4.6.2~pre1/src/command.c	2008-02-27 01:22:17.000000000 +0100
+@@ -44,6 +44,33 @@
+ /* This holds the command line */
+ WInput *cmdline;
+ 
++/* We'll get escaped strings now.. so we have to unescape them */
++char *
++unescape_string ( char * in ) {
++	char * local = NULL;
++	int i = 0;
++	int j = 20;
++	int k = 0;
++
++	local = g_malloc(j);
++	
++	for (i=0;i<=strlen(in);i++) {
++		if (i-k >= j ) {
++			j = j + 20;
++			local = g_realloc(local,j);
++		}
++		if ( (strchr(" \t*|;<>",in[i])) && ( strchr("\\",in[i-1])) ) {
++			k++;
++			local[i-k] = in[i];
++		} else {
++			local[i-k] = in[i];
++		}
++	}
++	local[i-k] = '\0';
++		
++	return local;
++}
++
+ /*
+  * Expand the argument to "cd" and change directory.  First try tilde
+  * expansion, then variable substitution.  If the CDPATH variable is set
+@@ -63,6 +90,7 @@
+     const char *t;
+ 
+     /* Tilde expansion */
++	path = unescape_string(path);
+     path_tilde = tilde_expand (path);
+ 
+     /* Leave space for further expansion */
+diff -Nurwd mc-4.6.2~pre1.orig/src/complete.c mc-4.6.2~pre1/src/complete.c
+--- mc-4.6.2~pre1.orig/src/complete.c	2008-02-27 01:26:38.000000000 +0100
++++ mc-4.6.2~pre1/src/complete.c	2008-02-27 01:26:01.000000000 +0100
+@@ -962,6 +962,34 @@
+     }
+ }
+ 
++char *
++escape_string ( char * in ) {
++	char * local = NULL;
++	int i = 0;
++	int j = 20;
++	int k = 0;
++
++	local = g_malloc(j);
++
++	for (i=0;i<strlen(in);i++) {
++		if (i+k >= j ) { //If 20 chars is too low for the path
++			j = j + 20;
++			local = g_realloc(local,j);
++		}
++		if ( (strchr(" \t*|;<>",in[i])) && (! strchr("\\",in[i-1])) ) {
++			local[i+k] = 92; // Ascii for "\"
++ 			k = k+1;
++			local[i+k] = in[i];
++		} else {
++			local[i+k] = in[i];
++		}
++	}
++	local[i+k] = '\0';
++	
++	return local;
++}
++
++
+ #define DO_INSERTION 1
+ #define DO_QUERY     2
+ /* Returns 1 if the user would like to see us again */
+@@ -969,6 +997,7 @@
+ complete_engine (WInput *in, int what_to_do)
+ {
+     int s;
++	char *complete = NULL;
+     
+     if (in->completions && (str_offset_to_pos (in->buffer, in->point)) != end)
+     	free_completions (in);
+@@ -985,7 +1014,8 @@
+     }
+     if (in->completions){
+     	if (what_to_do & DO_INSERTION || ((what_to_do & DO_QUERY) && !in->completions[1])) {
+-    	    if (insert_text (in, in->completions [0], strlen (in->completions [0]))){
++			complete = escape_string(in->completions [0]);
++    	    if (insert_text (in, complete, strlen (complete))){
+     	        if (in->completions [1])
+     	    	    beep ();
+ 		else
+@@ -1001,9 +1031,11 @@
+     	    Dlg_head *query_dlg;
+     	    WListbox *query_list;
+     	    
+-    	    for (p=in->completions + 1; *p; count++, p++)
++     	    for (p=in->completions + 1; *p; count++, p++) {
++    	    *p = escape_string(*p);
+     	    	if ((i = str_term_width1 (*p)) > maxlen)
+     	    	    maxlen = i;
++            }
+     	    start_x = in->widget.x;
+     	    start_y = in->widget.y;
+     	    if (start_y - 2 >= count) {




More information about the Pkg-mc-commits mailing list