Fossil SCM

Allow 8 *or more* digits in the "-v00000000" string that can be added to builtin filenames.

drh 2025-03-05 12:15 wasm-cache-workaround
Commit 81af7db0a3470cf7d7d779a47c3eee65980c006712fd8f282866afa3e08f7d21
1 file changed +5 -4
+5 -4
--- src/builtin.c
+++ src/builtin.c
@@ -56,23 +56,24 @@
5656
** Return a pointer to built-in content
5757
**
5858
** If the filename contains "-vNNNNNNNN" just before the final file
5959
** suffix, where each N is a random digit, then omit that part of the
6060
** filename before doing the lookup. The extra -vNNNNNNNN was added
61
-** to defeat overly aggressive caching by web browsers.
61
+** to defeat overly aggressive caching by web browsers. There must be
62
+** at least 8 digits in NNNNNNNN but more than 8 are allowed.
6263
*/
6364
const unsigned char *builtin_file(const char *zFilename, int *piSize){
6465
int i = builtin_file_index(zFilename);
6566
if( i>=0 ){
6667
if( piSize ) *piSize = aBuiltinFiles[i].nByte;
6768
return aBuiltinFiles[i].pData;
6869
}else{
6970
char *zV = strstr(zFilename, "-v");
7071
if( zV!=0 ){
71
- for(i=0; i<8 && fossil_isdigit(zV[i+2]); i++){}
72
- if( i==8 && zV[10]=='.' ){
73
- char *zNew = mprintf("%.*s%s", (int)(zV-zFilename), zFilename, zV+10);
72
+ for(i=0; fossil_isdigit(zV[i+2]); i++){}
73
+ if( i>=8 && zV[i+2]=='.' ){
74
+ char *zNew = mprintf("%.*s%s", (int)(zV-zFilename), zFilename, zV+i+2);
7475
const unsigned char *pRes = builtin_file(zNew, piSize);
7576
fossil_free(zNew);
7677
return pRes;
7778
}
7879
}
7980
--- src/builtin.c
+++ src/builtin.c
@@ -56,23 +56,24 @@
56 ** Return a pointer to built-in content
57 **
58 ** If the filename contains "-vNNNNNNNN" just before the final file
59 ** suffix, where each N is a random digit, then omit that part of the
60 ** filename before doing the lookup. The extra -vNNNNNNNN was added
61 ** to defeat overly aggressive caching by web browsers.
 
62 */
63 const unsigned char *builtin_file(const char *zFilename, int *piSize){
64 int i = builtin_file_index(zFilename);
65 if( i>=0 ){
66 if( piSize ) *piSize = aBuiltinFiles[i].nByte;
67 return aBuiltinFiles[i].pData;
68 }else{
69 char *zV = strstr(zFilename, "-v");
70 if( zV!=0 ){
71 for(i=0; i<8 && fossil_isdigit(zV[i+2]); i++){}
72 if( i==8 && zV[10]=='.' ){
73 char *zNew = mprintf("%.*s%s", (int)(zV-zFilename), zFilename, zV+10);
74 const unsigned char *pRes = builtin_file(zNew, piSize);
75 fossil_free(zNew);
76 return pRes;
77 }
78 }
79
--- src/builtin.c
+++ src/builtin.c
@@ -56,23 +56,24 @@
56 ** Return a pointer to built-in content
57 **
58 ** If the filename contains "-vNNNNNNNN" just before the final file
59 ** suffix, where each N is a random digit, then omit that part of the
60 ** filename before doing the lookup. The extra -vNNNNNNNN was added
61 ** to defeat overly aggressive caching by web browsers. There must be
62 ** at least 8 digits in NNNNNNNN but more than 8 are allowed.
63 */
64 const unsigned char *builtin_file(const char *zFilename, int *piSize){
65 int i = builtin_file_index(zFilename);
66 if( i>=0 ){
67 if( piSize ) *piSize = aBuiltinFiles[i].nByte;
68 return aBuiltinFiles[i].pData;
69 }else{
70 char *zV = strstr(zFilename, "-v");
71 if( zV!=0 ){
72 for(i=0; fossil_isdigit(zV[i+2]); i++){}
73 if( i>=8 && zV[i+2]=='.' ){
74 char *zNew = mprintf("%.*s%s", (int)(zV-zFilename), zFilename, zV+i+2);
75 const unsigned char *pRes = builtin_file(zNew, piSize);
76 fossil_free(zNew);
77 return pRes;
78 }
79 }
80

Keyboard Shortcuts

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