Fossil SCM
Ignore a trailing "/" on the name= query parameter for /file when showing a directory listing.
Commit
a9c4b3c4b441e4e8c52e695372ab7406692e0198bd58b822ea60a56b9b36dcda
Parent
6a01228fe1eb0a2…
1 file changed
+12
-8
+12
-8
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1897,18 +1897,22 @@ | ||
| 1897 | 1897 | " ORDER BY event.mtime DESC LIMIT 1", |
| 1898 | 1898 | zName |
| 1899 | 1899 | ); |
| 1900 | 1900 | /* If no file called NAME exists, instead look for a directory |
| 1901 | 1901 | ** with that name, and do a directory listing */ |
| 1902 | - if( rid==0 && db_exists( | |
| 1903 | - "SELECT 1 FROM filename" | |
| 1904 | - " WHERE name GLOB '%q/*' AND substr(name,1,length(%Q)+1)=='%q/';", | |
| 1905 | - zName, zName, zName | |
| 1906 | - ) ){ | |
| 1907 | - if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); | |
| 1908 | - page_tree(); | |
| 1909 | - return; | |
| 1902 | + if( rid==0 ){ | |
| 1903 | + int nName = (int)strlen(zName); | |
| 1904 | + if( nName && zName[nName-1]=='/' ) nName--; | |
| 1905 | + if( db_exists( | |
| 1906 | + "SELECT 1 FROM filename" | |
| 1907 | + " WHERE name GLOB '%.*q/*' AND substr(name,1,%d)=='%.*q/';", | |
| 1908 | + nName, zName, nName+1, nName, zName | |
| 1909 | + ) ){ | |
| 1910 | + if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); | |
| 1911 | + page_tree(); | |
| 1912 | + return; | |
| 1913 | + } | |
| 1910 | 1914 | } |
| 1911 | 1915 | /* If no file or directory called NAME: issue an error */ |
| 1912 | 1916 | if( rid==0 ){ |
| 1913 | 1917 | style_header("No such file"); |
| 1914 | 1918 | @ File '%h(zName)' does not exist in this repository. |
| 1915 | 1919 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1897,18 +1897,22 @@ | |
| 1897 | " ORDER BY event.mtime DESC LIMIT 1", |
| 1898 | zName |
| 1899 | ); |
| 1900 | /* If no file called NAME exists, instead look for a directory |
| 1901 | ** with that name, and do a directory listing */ |
| 1902 | if( rid==0 && db_exists( |
| 1903 | "SELECT 1 FROM filename" |
| 1904 | " WHERE name GLOB '%q/*' AND substr(name,1,length(%Q)+1)=='%q/';", |
| 1905 | zName, zName, zName |
| 1906 | ) ){ |
| 1907 | if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); |
| 1908 | page_tree(); |
| 1909 | return; |
| 1910 | } |
| 1911 | /* If no file or directory called NAME: issue an error */ |
| 1912 | if( rid==0 ){ |
| 1913 | style_header("No such file"); |
| 1914 | @ File '%h(zName)' does not exist in this repository. |
| 1915 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1897,18 +1897,22 @@ | |
| 1897 | " ORDER BY event.mtime DESC LIMIT 1", |
| 1898 | zName |
| 1899 | ); |
| 1900 | /* If no file called NAME exists, instead look for a directory |
| 1901 | ** with that name, and do a directory listing */ |
| 1902 | if( rid==0 ){ |
| 1903 | int nName = (int)strlen(zName); |
| 1904 | if( nName && zName[nName-1]=='/' ) nName--; |
| 1905 | if( db_exists( |
| 1906 | "SELECT 1 FROM filename" |
| 1907 | " WHERE name GLOB '%.*q/*' AND substr(name,1,%d)=='%.*q/';", |
| 1908 | nName, zName, nName+1, nName, zName |
| 1909 | ) ){ |
| 1910 | if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); |
| 1911 | page_tree(); |
| 1912 | return; |
| 1913 | } |
| 1914 | } |
| 1915 | /* If no file or directory called NAME: issue an error */ |
| 1916 | if( rid==0 ){ |
| 1917 | style_header("No such file"); |
| 1918 | @ File '%h(zName)' does not exist in this repository. |
| 1919 |