Fossil SCM

Ignore a trailing "/" on the name= query parameter for /file when showing a directory listing.

drh 2017-03-15 19:50 trunk
Commit a9c4b3c4b441e4e8c52e695372ab7406692e0198bd58b822ea60a56b9b36dcda
1 file changed +12 -8
+12 -8
--- src/info.c
+++ src/info.c
@@ -1897,18 +1897,22 @@
18971897
" ORDER BY event.mtime DESC LIMIT 1",
18981898
zName
18991899
);
19001900
/* If no file called NAME exists, instead look for a directory
19011901
** 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
+ }
19101914
}
19111915
/* If no file or directory called NAME: issue an error */
19121916
if( rid==0 ){
19131917
style_header("No such file");
19141918
@ File '%h(zName)' does not exist in this repository.
19151919
--- 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

Keyboard Shortcuts

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