diff -rNu mc-4.8.13/lib/strescape.h mc-new/lib/strescape.h
old
|
new
|
|
29 | 29 | |
30 | 30 | gboolean strutils_is_char_escaped (const char *, const char *); |
31 | 31 | |
| 32 | /* |
| 33 | In-place unescaping of http %xx sequences. |
| 34 | */ |
| 35 | void strutils_url_unescape(char *buff); |
| 36 | |
32 | 37 | #endif |
diff -rNu mc-4.8.13/lib/strutil/strescape.c mc-new/lib/strutil/strescape.c
old
|
new
|
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /* --------------------------------------------------------------------------------------------- */ |
| 256 | |
| 257 | /* unescape auxiliary function */ |
| 258 | |
| 259 | /* |
| 260 | returns the (integer) digit value to the character, |
| 261 | or -1 if not in the valid set '0' ... '9', 'A' ... F' |
| 262 | */ |
| 263 | static unsigned int |
| 264 | digit_heximal(char dig) |
| 265 | { |
| 266 | |
| 267 | if ((dig >= '0') && (dig <= '9')) { |
| 268 | return dig - '0'; |
| 269 | } |
| 270 | if (dig > 'F') { dig -= 0x20; } |
| 271 | if ((dig >= 'A') && (dig <= 'F')) { |
| 272 | return dig - 0x37; |
| 273 | } |
| 274 | return -1; |
| 275 | } |
| 276 | |
| 277 | /* |
| 278 | Scans the srce string converting valid %cc hex escapes to their |
| 279 | ascii representation into the dest string. |
| 280 | Srce and dest refer to the same buffer without any ill effects. |
| 281 | */ |
| 282 | |
| 283 | void |
| 284 | strutils_url_unescape(char *buff) |
| 285 | { |
| 286 | char *psrc = buff; |
| 287 | char *pdst = buff; |
| 288 | short int hex8; |
| 289 | short int low8; |
| 290 | int copy = 0; |
| 291 | |
| 292 | while (*psrc != 0) { |
| 293 | if (*psrc != '%') { |
| 294 | if (copy) { *pdst++ = *psrc++; continue; } |
| 295 | else { pdst++; psrc++; continue; } |
| 296 | } |
| 297 | copy = 1; |
| 298 | // %% escape ? |
| 299 | if (*(++psrc) == '%') { |
| 300 | *pdst++ = *psrc++; continue; |
| 301 | } |
| 302 | hex8 = 16 * digit_heximal(*psrc++); |
| 303 | low8 = digit_heximal(*psrc++); |
| 304 | if ((low8 | hex8) < 0) { |
| 305 | // not a valid url escape - leave unmodified |
| 306 | *pdst++ = '%'; |
| 307 | *pdst++ = *(psrc - 2); |
| 308 | *pdst++ = *(psrc - 1); |
| 309 | } else { |
| 310 | *pdst++ = (char) (hex8 + low8); |
| 311 | } |
| 312 | } |
| 313 | *pdst = 0; |
| 314 | } |
| 315 | |
| 316 | /* --------------------------------------------------------------------------------------------- */ |
diff -rNu mc-4.8.13/src/vfs/ftpfs/ftpfs.c mc-new/src/vfs/ftpfs/ftpfs.c
old
|
new
|
|
110 | 110 | #include "lib/vfs/netutil.h" |
111 | 111 | #include "lib/vfs/xdirentry.h" |
112 | 112 | #include "lib/vfs/gc.h" /* vfs_stamp_create */ |
| 113 | #include "lib/strescape.h" |
113 | 114 | |
114 | 115 | #include "ftpfs.h" |
115 | 116 | |
… |
… |
|
622 | 623 | else |
623 | 624 | name = g_strdup (super->path_element->user); |
624 | 625 | |
| 626 | strutils_url_unescape(name); |
| 627 | |
625 | 628 | if (ftpfs_get_reply (me, SUP->sock, reply_string, sizeof (reply_string) - 1) == COMPLETE) |
626 | 629 | { |
627 | 630 | char *reply_up; |