Fossil

Diff
Login

Differences From Artifact [368fb9e30f]:

To Artifact [22be57b1eb]:


545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
545
546
547
548
549
550
551


552
553
554
555
556
557
558







-
-







          return 0;
        }
        if( (z[++i]&0xc0)!=0x80 ){
          /* Invalid second continuation byte */
          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;
      }
790
791
792
793
794
795
796
797
798


799
800
801
802
803
804
805
806
807
808

809

810
811
812
813
814
815
816
788
789
790
791
792
793
794


795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816







-
-
+
+










+

+







    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.
** Canonical names are full pathnames which contain no "/./" or "/../"
** terms and (On Windows/Cygwin) using "/" not "\".
*/
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) || defined(__CYGWIN__)
    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;
      }
    }
  }