|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/port/path.c,v 1.26 2004/08/01 06:56:39 momjian Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/port/path.c,v 1.27 2004/08/09 20:20:46 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -116,11 +116,33 @@ canonicalize_path(char *path)
|
116 | 116 | #endif
|
117 | 117 |
|
118 | 118 | /*
|
119 |
| - * Removing the trailing slash on a path means we never get |
120 |
| - * ugly double slashes. Don't remove a leading slash, though. |
121 |
| - * Also, Win32 can't stat() a directory with a trailing slash. |
| 119 | + * Removing the trailing slash on a path means we never get ugly double |
| 120 | + * slashes. Also, Win32 can't stat() a directory with a trailing slash. |
| 121 | + * Don't remove a leading slash, though. |
122 | 122 | */
|
123 | 123 | trim_trailing_separator(path);
|
| 124 | + |
| 125 | + /* |
| 126 | + * Remove any trailing uses of "." or "..", too. |
| 127 | + */ |
| 128 | + for (;;) |
| 129 | + { |
| 130 | + int len = strlen(path); |
| 131 | + |
| 132 | + if (len >= 2 && strcmp(path + len - 2, "/.") == 0) |
| 133 | + { |
| 134 | + trim_directory(path); |
| 135 | + trim_trailing_separator(path); |
| 136 | + } |
| 137 | + else if (len >= 3 && strcmp(path + len - 3, "/..") == 0) |
| 138 | + { |
| 139 | + trim_directory(path); |
| 140 | + trim_directory(path); |
| 141 | + trim_trailing_separator(path); |
| 142 | + } |
| 143 | + else |
| 144 | + break; |
| 145 | + } |
124 | 146 | }
|
125 | 147 |
|
126 | 148 |
|
@@ -444,7 +466,7 @@ trim_trailing_separator(char *path)
|
444 | 466 | #ifdef WIN32
|
445 | 467 | /*
|
446 | 468 | * Skip over network and drive specifiers for win32.
|
447 |
| - * Set 'path' to point to the last character to keep. |
| 469 | + * Set 'path' to point to the last character we must keep. |
448 | 470 | */
|
449 | 471 | if (strlen(path) >= 2)
|
450 | 472 | {
|
|
0 commit comments