Fossil SCM
Fix to the pathname simplifer logic.
Commit
d31c0f9c29b27aa9deaae9adde86a94cebc2e43d
Parent
0a523be389f9efe…
1 file changed
+3
-2
+3
-2
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -207,11 +207,11 @@ | ||
| 207 | 207 | /* |
| 208 | 208 | ** Simplify a filename by |
| 209 | 209 | ** |
| 210 | 210 | ** * removing any trailing and duplicate / |
| 211 | 211 | ** * removing /./ |
| 212 | -** * removing /A/./ | |
| 212 | +** * removing /A/../ | |
| 213 | 213 | ** |
| 214 | 214 | ** Changes are made in-place. Return the new name length. |
| 215 | 215 | */ |
| 216 | 216 | int file_simplify_name(char *z, int n){ |
| 217 | 217 | int i, j; |
| @@ -223,11 +223,12 @@ | ||
| 223 | 223 | i += 1; |
| 224 | 224 | continue; |
| 225 | 225 | } |
| 226 | 226 | if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){ |
| 227 | 227 | while( j>0 && z[j-1]!='/' ){ j--; } |
| 228 | - i += 3; | |
| 228 | + if( j>0 ){ j--; } | |
| 229 | + i += 2; | |
| 229 | 230 | continue; |
| 230 | 231 | } |
| 231 | 232 | } |
| 232 | 233 | z[j++] = z[i]; |
| 233 | 234 | } |
| 234 | 235 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -207,11 +207,11 @@ | |
| 207 | /* |
| 208 | ** Simplify a filename by |
| 209 | ** |
| 210 | ** * removing any trailing and duplicate / |
| 211 | ** * removing /./ |
| 212 | ** * removing /A/./ |
| 213 | ** |
| 214 | ** Changes are made in-place. Return the new name length. |
| 215 | */ |
| 216 | int file_simplify_name(char *z, int n){ |
| 217 | int i, j; |
| @@ -223,11 +223,12 @@ | |
| 223 | i += 1; |
| 224 | continue; |
| 225 | } |
| 226 | if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){ |
| 227 | while( j>0 && z[j-1]!='/' ){ j--; } |
| 228 | i += 3; |
| 229 | continue; |
| 230 | } |
| 231 | } |
| 232 | z[j++] = z[i]; |
| 233 | } |
| 234 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -207,11 +207,11 @@ | |
| 207 | /* |
| 208 | ** Simplify a filename by |
| 209 | ** |
| 210 | ** * removing any trailing and duplicate / |
| 211 | ** * removing /./ |
| 212 | ** * removing /A/../ |
| 213 | ** |
| 214 | ** Changes are made in-place. Return the new name length. |
| 215 | */ |
| 216 | int file_simplify_name(char *z, int n){ |
| 217 | int i, j; |
| @@ -223,11 +223,12 @@ | |
| 223 | i += 1; |
| 224 | continue; |
| 225 | } |
| 226 | if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){ |
| 227 | while( j>0 && z[j-1]!='/' ){ j--; } |
| 228 | if( j>0 ){ j--; } |
| 229 | i += 2; |
| 230 | continue; |
| 231 | } |
| 232 | } |
| 233 | z[j++] = z[i]; |
| 234 | } |
| 235 |