(mh_expand_name): Correctly handle full and relative pathname specifications.
Showing
1 changed file
with
17 additions
and
1 deletions
... | @@ -342,15 +342,31 @@ mh_expand_name (const char *base, const char *name, int is_folder) | ... | @@ -342,15 +342,31 @@ mh_expand_name (const char *base, const char *name, int is_folder) |
342 | tmp = mu_tilde_expansion (name, "/", NULL); | 342 | tmp = mu_tilde_expansion (name, "/", NULL); |
343 | if (tmp[0] == '+') | 343 | if (tmp[0] == '+') |
344 | name = tmp + 1; | 344 | name = tmp + 1; |
345 | else if (strncmp (tmp, "../", 3) == 0 || strncmp (tmp, "./", 2) == 0) | ||
346 | { | ||
347 | char *cwd = mu_getcwd (); | ||
348 | asprintf (&name, "%s/%s", cwd, tmp); | ||
349 | free (cwd); | ||
350 | free (tmp); | ||
351 | tmp = NULL; | ||
352 | } | ||
345 | else | 353 | else |
346 | name = tmp; | 354 | name = tmp; |
347 | 355 | ||
348 | if (!base) | 356 | if (!base) |
349 | base = mu_path_folder_dir; | 357 | base = mu_path_folder_dir; |
350 | if (is_folder) | 358 | if (is_folder) |
351 | asprintf (&p, "mh:%s/%s", base, name); | 359 | { |
360 | if (name[0] == '/') | ||
361 | asprintf (&p, "mh:%s", name); | ||
352 | else | 362 | else |
363 | asprintf (&p, "mh:%s/%s", base, name); | ||
364 | } | ||
365 | else if (name[0] != '/') | ||
353 | asprintf (&p, "%s/%s", base, name); | 366 | asprintf (&p, "%s/%s", base, name); |
367 | else | ||
368 | return name; | ||
369 | |||
354 | free (tmp); | 370 | free (tmp); |
355 | return p; | 371 | return p; |
356 | } | 372 | } | ... | ... |
-
Please register or sign in to post a comment