Fossil SCM

Strengthen the file_is_canonical() routine so that it returns false on Windows if the pathname does not begin with a drive letter.

drh 2024-11-21 13:34 trunk
Commit f6ff25e1b75579a88c7189fc0ea69eb0f5389d0717942e7c56183338d2b5b937
1 file changed +4 -2
+4 -2
--- src/file.c
+++ src/file.c
@@ -1711,13 +1711,15 @@
17111711
** Canonical names are full pathnames using "/" not "\" and which
17121712
** contain no "/./" or "/../" terms.
17131713
*/
17141714
int file_is_canonical(const char *z){
17151715
int i;
1716
- if( z[0]!='/'
1716
+ if(
17171717
#if defined(_WIN32) || defined(__CYGWIN__)
1718
- && (!fossil_isupper(z[0]) || z[1]!=':' || z[2]!='/')
1718
+ !fossil_isupper(z[0]) || z[1]!=':' || !fossil_isdirsep(z[2])
1719
+#else
1720
+ z[0]!='/'
17191721
#endif
17201722
) return 0;
17211723
17221724
for(i=0; z[i]; i++){
17231725
if( z[i]=='\\' ) return 0;
17241726
--- src/file.c
+++ src/file.c
@@ -1711,13 +1711,15 @@
1711 ** Canonical names are full pathnames using "/" not "\" and which
1712 ** contain no "/./" or "/../" terms.
1713 */
1714 int file_is_canonical(const char *z){
1715 int i;
1716 if( z[0]!='/'
1717 #if defined(_WIN32) || defined(__CYGWIN__)
1718 && (!fossil_isupper(z[0]) || z[1]!=':' || z[2]!='/')
 
 
1719 #endif
1720 ) return 0;
1721
1722 for(i=0; z[i]; i++){
1723 if( z[i]=='\\' ) return 0;
1724
--- src/file.c
+++ src/file.c
@@ -1711,13 +1711,15 @@
1711 ** Canonical names are full pathnames using "/" not "\" and which
1712 ** contain no "/./" or "/../" terms.
1713 */
1714 int file_is_canonical(const char *z){
1715 int i;
1716 if(
1717 #if defined(_WIN32) || defined(__CYGWIN__)
1718 !fossil_isupper(z[0]) || z[1]!=':' || !fossil_isdirsep(z[2])
1719 #else
1720 z[0]!='/'
1721 #endif
1722 ) return 0;
1723
1724 for(i=0; z[i]; i++){
1725 if( z[i]=='\\' ) return 0;
1726

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button