Fossil

Check-in [c3d74f4f63]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Allow backslash in filenames on UNIX (experiment)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | allow-backslash-on-unix
Files: files | file ages | folders
SHA1: c3d74f4f633e4b28adb4e18baaee78a6482ed4c8
User & Date: jan.nijtmans 2012-12-20 22:59:20.501
Context
2013-01-27
20:29
merge trunk, combine with "allow-backslash-on-unix" branch check-in: 38159dae32 user: jan.nijtmans tags: ticket-d17d6e5b17
2012-12-20
22:59
Allow backslash in filenames on UNIX (experiment) Closed-Leaf check-in: c3d74f4f63 user: jan.nijtmans tags: allow-backslash-on-unix
2012-12-19
08:24
Allow backslash in card filenames without causing a SYNTAX error in card parsing. check-in: 0a24257420 user: jan.nijtmans tags: allow-backslash-in-card-filename
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/file.c.
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
            }
          } else if( ((c & 0xff) == 0xed) && ((z[i+1] & 0xe0) == 0xa0) ){
            /* Unicode character in the range U+D800 - U+DFFF are for
             * surrogate pairs, they shouldn't occur in filenames. */
            return 0;
          }
        }
      }else 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;







<
<







521
522
523
524
525
526
527


528
529
530
531
532
533
534
            }
          } else if( ((c & 0xff) == 0xed) && ((z[i+1] & 0xe0) == 0xa0) ){
            /* Unicode character in the range U+D800 - U+DFFF are for
             * surrogate pairs, they shouldn't occur in filenames. */
            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;
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785

786

787
788
789
790
791
792
793
    fossil_print("  file_isdir  = %d\n", file_wd_isdir(zName));
  }
}

/*
** Return TRUE if the given filename is canonical.
**
** Canonical names are full pathnames using "/" not "\" and which
** contain no "/./" or "/../" terms.
*/
int file_is_canonical(const char *z){
  int i;
  if( z[0]!='/'
#if defined(_WIN32)
    && (z[0]==0 || z[1]!=':' || z[2]!='/')
#endif
  ) return 0;

  for(i=0; z[i]; i++){

    if( z[i]=='\\' ) return 0;

    if( z[i]=='/' ){
      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;
      }
    }
  }







|
|










>

>







765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
    fossil_print("  file_isdir  = %d\n", file_wd_isdir(zName));
  }
}

/*
** Return TRUE if the given filename is canonical.
**
** Canonical names are full pathnames using "/" not "\" (on Windows)
** and which contain no "/./" or "/../" terms.
*/
int file_is_canonical(const char *z){
  int i;
  if( z[0]!='/'
#if defined(_WIN32)
    && (z[0]==0 || z[1]!=':' || z[2]!='/')
#endif
  ) return 0;

  for(i=0; z[i]; i++){
#if defined(_WIN32)
    if( z[i]=='\\' ) return 0;
#endif
    if( z[i]=='/' ){
      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;
      }
    }
  }