Differences From Artifact [69361fbe16]:
- File
src/file.c
— part of check-in
[b59dc07818]
at
2012-11-21 09:12:35
on branch ticket-d17d6e5b17
— Split off in separate functions
Still experimental, but starts looking better
(user: jan.nijtmans size: 33376)
To Artifact [8ffecbc457]:
- File src/file.c — part of check-in [9272573511] at 2012-11-21 09:20:15 on branch ticket-d17d6e5b17 — Somehow, part of previous change got lost (user: jan.nijtmans size: 33332)
| ︙ | ︙ | |||
479 480 481 482 483 484 485 | /* ** Return true if the filename given is a valid filename for ** a file in a repository. Valid filenames follow all of the ** following rules: ** ** * Does not begin with "/" ** * Does not contain any path element named "." or ".." | | | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
/*
** Return true if the filename given is a valid filename for
** a file in a repository. Valid filenames follow all of the
** following rules:
**
** * Does not begin with "/"
** * Does not contain any path element named "." or ".."
** * Does not contain any of these characters in the path: "\"
** * Does not end with "/".
** * Does not contain two or more "/" characters in a row.
** * Contains at least one character
*/
int file_is_simple_pathname(const char *z){
int i;
char c = z[0];
if( c=='/' || c==0 ) return 0;
if( c=='.' ){
if( z[1]=='/' || z[1]==0 ) return 0;
if( z[1]=='.' && (z[2]=='/' || z[2]==0) ) return 0;
}
for(i=0; (c=z[i])!=0; i++){
if( c=='\\' ){
return 0;
}
if( c=='/' ){
if( z[i+1]=='/' ) return 0;
if( z[i+1]=='.' ){
if( z[i+2]=='/' || z[i+2]==0 ) return 0;
if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
|
| ︙ | ︙ |