~ubuntu-branches/ubuntu/lucid/mc/lucid

« back to all changes in this revision

Viewing changes to debian/patches/bugs/61_escaping.patch

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Winnertz
  • Date: 2008-09-16 10:38:59 UTC
  • mfrom: (3.1.6 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080916103859-2uwn8w61xk5mbxxq
Tags: 2:4.6.2~git20080311-4
Corrected fix for odt2txt issue (Closes: #492019) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -u -w -r1.141 util.c
 
2
--- ./src/util.c        25 Sep 2007 15:33:37 -0000      1.141
 
3
+++ ./src/util.c        27 Feb 2008 15:38:13 -0000
 
4
@@ -1525,3 +1525,58 @@
 
5
     return (sep != NULL) ? sep + 1 : result;
 
6
 }
 
7
 
 
8
+/* Unescape paths or other strings for e.g the internal cd  */
 
9
+char *
 
10
+unescape_string ( const char * in ) {
 
11
+       char * local = NULL;
 
12
+       int i = 0;
 
13
+       int j = 20;
 
14
+       int k = 0;
 
15
+
 
16
+       local = g_malloc(j);
 
17
+       
 
18
+       for (i=0;i<=strlen(in);i++) {
 
19
+               if (i-k+1 >= j ) {
 
20
+                       j = j + 20;
 
21
+                       local = g_realloc(local,j);
 
22
+               }
 
23
+               if ( (strchr(" \t*|;<>~#()?[]{}&",in[i])) && ( strchr("\\",in[i-1])) ) {
 
24
+                       k++;
 
25
+                       local[i-k] = in[i];
 
26
+               } else {
 
27
+                       local[i-k] = in[i];
 
28
+               }
 
29
+       }
 
30
+       local[i-k] = '\0';
 
31
+       
 
32
+       return local;
 
33
+}
 
34
+
 
35
+/* To be compatible with the general posix command lines we have to escape *
 
36
+ * strings for the command line                                                                                           */
 
37
+char *
 
38
+escape_string ( const char * in ) {
 
39
+       char * local = NULL;
 
40
+       int i = 0;
 
41
+       int j = 20;
 
42
+       int k = 0;
 
43
+
 
44
+       local = g_malloc(j);
 
45
+
 
46
+       for (i=0;i<strlen(in);i++) {
 
47
+               if (i+k+1 >= j ) { //If 20 chars is too low for the path
 
48
+                       j = j + 20;
 
49
+                       local = g_realloc(local,j);
 
50
+               }
 
51
+               if ( (strchr(" \t*|;<>~#()?[]{}&",in[i])) && (! strchr("\\",in[i-1])) ) {
 
52
+                       local[i+k] = 92; // Ascii for "\"
 
53
+                       k = k+1;
 
54
+                       local[i+k] = in[i];
 
55
+               } else {
 
56
+                       local[i+k] = in[i];
 
57
+               }
 
58
+       }
 
59
+       local[i+k] = '\0';
 
60
+
 
61
+       return local;
 
62
+}
 
63
diff -u -w -r1.78 util.h
 
64
--- ./src/util.h        3 Feb 2006 17:04:17 -0000       1.78
 
65
+++ ./src/util.h        27 Feb 2008 15:38:13 -0000
 
66
@@ -14,6 +14,8 @@
 
67
 extern const char *cstrcasestr (const char *haystack, const char *needle);
 
68
 extern const char *cstrstr (const char *haystack, const char *needle);
 
69
 
 
70
+char *unescape_string ( const char * in );
 
71
+char *escape_string ( const char * in );
 
72
 void str_replace(char *s, char from, char to);
 
73
 int  is_printable (int c);
 
74
 void msglen (const char *text, /*@out@*/ int *lines, /*@out@*/ int *columns);
 
75
diff -u -w -r1.61 complete.c
 
76
--- ./src/complete.c    25 Sep 2007 15:33:36 -0000      1.61
 
77
+++ ./src/complete.c    27 Feb 2008 15:38:14 -0000
 
78
@@ -40,6 +40,7 @@
 
79
 #include "wtools.h"
 
80
 #include "complete.h"
 
81
 #include "main.h"
 
82
+#include "util.h"
 
83
 #include "key.h"               /* XCTRL and ALT macros */
 
84
 
 
85
 typedef char *CompletionFunction (char *, int);
 
86
@@ -911,6 +912,7 @@
 
87
 static int
 
88
 complete_engine (WInput *in, int what_to_do)
 
89
 {
 
90
+    char *complete = NULL;
 
91
     if (in->completions && in->point != end)
 
92
        free_completions (in);
 
93
     if (!in->completions){
 
94
@@ -924,7 +926,8 @@
 
95
     }
 
96
     if (in->completions){
 
97
        if (what_to_do & DO_INSERTION || ((what_to_do & DO_QUERY) && !in->completions[1])) {
 
98
-           if (insert_text (in, in->completions [0], strlen (in->completions [0]))){
 
99
+           complete = escape_string(in->completions [0]);
 
100
+           if (insert_text (in, complete, strlen (complete))){
 
101
                if (in->completions [1])
 
102
                    beep ();
 
103
                else
 
104
@@ -940,9 +943,11 @@
 
105
            Dlg_head *query_dlg;
 
106
            WListbox *query_list;
 
107
            
 
108
-           for (p=in->completions + 1; *p; count++, p++)
 
109
+           for (p=in->completions + 1; *p; count++, p++) {
 
110
+           *p = escape_string(*p);
 
111
                if ((i = strlen (*p)) > maxlen)
 
112
                    maxlen = i;
 
113
+                       }
 
114
            start_x = in->widget.x;
 
115
            start_y = in->widget.y;
 
116
            if (start_y - 2 >= count) {
 
117
diff -u -w -r1.34 command.c
 
118
--- ./src/command.c     26 Sep 2007 10:22:25 -0000      1.34
 
119
+++ ./src/command.c     27 Feb 2008 15:38:15 -0000
 
120
@@ -64,6 +64,7 @@
 
121
     const char *t;
 
122
 
 
123
     /* Tilde expansion */
 
124
+    path = unescape_string(path);
 
125
     path_tilde = tilde_expand (path);
 
126
 
 
127
     /* Leave space for further expansion */
 
128
diff -u -w -r1.151 file.c
 
129
--- ./src/file.c        25 Sep 2007 15:33:36 -0000      1.151
 
130
+++ ./src/file.c        5 Mar 2008 09:15:47 -0000
 
131
@@ -63,6 +63,7 @@
 
132
 #include "widget.h"
 
133
 #include "wtools.h"
 
134
 #include "background.h"                /* we_are_background */
 
135
+#include "util.h"
 
136
 
 
137
 /* Needed for current_panel, other_panel and WTree */
 
138
 #include "dir.h"
 
139
@@ -791,7 +807,7 @@
 
140
            }
 
141
        }
 
142
 
 
143
-       if (!appending) {
 
144
+       if (!appending && ctx->preserve) {
 
145
            while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) {
 
146
                temp_status = file_error (
 
147
                        _(" Cannot chmod target file \"%s\" \n %s "), dst_path);
 
148
@@ -1872,6 +1890,8 @@
 
149
                dest = temp2;
 
150
                temp = NULL;
 
151
 
 
152
+               source_with_path = unescape_string(source_with_path);
 
153
+               dest = unescape_string(dest);
 
154
                switch (operation) {
 
155
                case OP_COPY:
 
156
                    /*
 
157
@@ -1963,6 +1983,9 @@
 
158
                else {
 
159
                    char *temp2 = concat_dir_and_file (dest, temp);
 
160
 
 
161
+                       source_with_path = unescape_string(source_with_path);
 
162
+                       temp2 = unescape_string(temp2);
 
163
+                       
 
164
                    switch (operation) {
 
165
                    case OP_COPY:
 
166
                        /*