Fossil SCM

Do not generate tarball hyperlinks unless we are sure the client is not a spider.

drh 2025-10-18 19:28 timeline-enhance-2025
Commit 878407b82dad453c7197dcb71f5de9b230aff4ac4dedc062198a08ff9394f3fc
3 files changed +12 -8 +40 -12 +1 -2
+12 -8
--- src/info.c
+++ src/info.c
@@ -993,19 +993,23 @@
993993
@ <tr><th>Comment:</th><td class="infoComment">\
994994
@ %!W(zEComment?zEComment:zComment)</td></tr>
995995
996996
/* The Download: line */
997997
if( g.perm.Zip ){
998
- char *zBase = archive_base_name(rid);
999998
@ <tr><th>Downloads:</th><td>
1000
- @ %z(href("%R/tarball/%S/%s.tar.gz",zUuid,zBase))Tarball</a>
1001
- @ | %z(href("%R/zip/%S/%s.zip",zUuid,zBase))ZIP archive</a>
1002
- if( g.zLogin!=0 ){
1003
- @ | %z(href("%R/sqlar/%S/%s.sqlar",zUuid,zBase))\
1004
- @ SQL archive</a></td></tr>
999
+ if( robot_would_be_restricted("download") ){
1000
+ @ See separate %z(href("%R/rchvdwnld/%!S",zUuid))download page</a>
1001
+ }else{
1002
+ char *zBase = archive_base_name(rid);
1003
+ @ %z(href("%R/tarball/%S/%s.tar.gz",zUuid,zBase))Tarball</a>
1004
+ @ | %z(href("%R/zip/%S/%s.zip",zUuid,zBase))ZIP archive</a>
1005
+ if( g.zLogin!=0 ){
1006
+ @ | %z(href("%R/sqlar/%S/%s.sqlar",zUuid,zBase))\
1007
+ @ SQL archive</a></td></tr>
1008
+ }
1009
+ fossil_free(zBase);
10051010
}
1006
- fossil_free(zBase);
10071011
}
10081012
10091013
@ <tr><th>Timelines:</th><td>
10101014
@ %z(href("%R/timeline?f=%!S&unhide",zUuid))family</a>
10111015
if( zParent ){
@@ -1935,11 +1939,11 @@
19351939
int dflt;
19361940
int res;
19371941
int isBot;
19381942
static char zDflt[2]
19391943
/*static b/c cookie_link_parameter() does not copy it!*/;
1940
- if( client_might_be_a_robot() && robot_restrict_has_tag("diff") ){
1944
+ if( robot_would_be_restricted("diff") ){
19411945
dflt = 0;
19421946
isBot = 1;
19431947
}else{
19441948
dflt = db_get_int("preferred-diff-type",-99);
19451949
if( dflt<=0 ) dflt = user_agent_is_likely_mobile() ? 1 : 2;
19461950
--- src/info.c
+++ src/info.c
@@ -993,19 +993,23 @@
993 @ <tr><th>Comment:</th><td class="infoComment">\
994 @ %!W(zEComment?zEComment:zComment)</td></tr>
995
996 /* The Download: line */
997 if( g.perm.Zip ){
998 char *zBase = archive_base_name(rid);
999 @ <tr><th>Downloads:</th><td>
1000 @ %z(href("%R/tarball/%S/%s.tar.gz",zUuid,zBase))Tarball</a>
1001 @ | %z(href("%R/zip/%S/%s.zip",zUuid,zBase))ZIP archive</a>
1002 if( g.zLogin!=0 ){
1003 @ | %z(href("%R/sqlar/%S/%s.sqlar",zUuid,zBase))\
1004 @ SQL archive</a></td></tr>
 
 
 
 
 
 
1005 }
1006 fossil_free(zBase);
1007 }
1008
1009 @ <tr><th>Timelines:</th><td>
1010 @ %z(href("%R/timeline?f=%!S&unhide",zUuid))family</a>
1011 if( zParent ){
@@ -1935,11 +1939,11 @@
1935 int dflt;
1936 int res;
1937 int isBot;
1938 static char zDflt[2]
1939 /*static b/c cookie_link_parameter() does not copy it!*/;
1940 if( client_might_be_a_robot() && robot_restrict_has_tag("diff") ){
1941 dflt = 0;
1942 isBot = 1;
1943 }else{
1944 dflt = db_get_int("preferred-diff-type",-99);
1945 if( dflt<=0 ) dflt = user_agent_is_likely_mobile() ? 1 : 2;
1946
--- src/info.c
+++ src/info.c
@@ -993,19 +993,23 @@
993 @ <tr><th>Comment:</th><td class="infoComment">\
994 @ %!W(zEComment?zEComment:zComment)</td></tr>
995
996 /* The Download: line */
997 if( g.perm.Zip ){
 
998 @ <tr><th>Downloads:</th><td>
999 if( robot_would_be_restricted("download") ){
1000 @ See separate %z(href("%R/rchvdwnld/%!S",zUuid))download page</a>
1001 }else{
1002 char *zBase = archive_base_name(rid);
1003 @ %z(href("%R/tarball/%S/%s.tar.gz",zUuid,zBase))Tarball</a>
1004 @ | %z(href("%R/zip/%S/%s.zip",zUuid,zBase))ZIP archive</a>
1005 if( g.zLogin!=0 ){
1006 @ | %z(href("%R/sqlar/%S/%s.sqlar",zUuid,zBase))\
1007 @ SQL archive</a></td></tr>
1008 }
1009 fossil_free(zBase);
1010 }
 
1011 }
1012
1013 @ <tr><th>Timelines:</th><td>
1014 @ %z(href("%R/timeline?f=%!S&unhide",zUuid))family</a>
1015 if( zParent ){
@@ -1935,11 +1939,11 @@
1939 int dflt;
1940 int res;
1941 int isBot;
1942 static char zDflt[2]
1943 /*static b/c cookie_link_parameter() does not copy it!*/;
1944 if( robot_would_be_restricted("diff") ){
1945 dflt = 0;
1946 isBot = 1;
1947 }else{
1948 dflt = db_get_int("preferred-diff-type",-99);
1949 if( dflt<=0 ) dflt = user_agent_is_likely_mobile() ? 1 : 2;
1950
+40 -12
--- src/robot.c
+++ src/robot.c
@@ -325,11 +325,11 @@
325325
326326
/*
327327
** Return true if zTag matches one of the tags in the robot-restrict
328328
** setting.
329329
*/
330
-int robot_restrict_has_tag(const char *zTag){
330
+static int robot_restrict_has_tag(const char *zTag){
331331
static const char *zGlob = 0;
332332
if( zGlob==0 ){
333333
zGlob = db_get("robot-restrict",robot_restrict_default());
334334
if( zGlob==0 ) zGlob = "";
335335
}
@@ -409,32 +409,60 @@
409409
fossil_free(zRequest);
410410
return bMatch;
411411
}
412412
413413
/*
414
-** Check to see if the page named in the argument is on the
415
-** robot-restrict list. If it is on the list and if the user
416
-** is "nobody" then bring up a captcha to test to make sure that
417
-** client is not a robot.
414
+** Return true if one or more of the conditions below are true.
415
+** Return false if all of the following are false:
416
+**
417
+** * The zTag is on the robot-restrict list
418
+**
419
+** * The client that submitted the HTTP request might be
420
+** a robot
421
+**
422
+** * The Request URI does not match any of the exceptions
423
+** in the robot-exception setting.
424
+**
425
+** In other words, return true if a call to robot_restrict() would
426
+** return true and false if a call to robot_restrict() would return
427
+** false.
418428
**
419
-** This routine returns true if a captcha was rendered and if subsequent
420
-** page generation should be aborted. It returns false if the page
421
-** should not be restricted and should be rendered normally.
429
+** The difference between this routine an robot_restrict() is that
430
+** this routine does not generate a proof-of-work captcha. This
431
+** routine does not change the HTTP reply in any way. It simply
432
+** returns true or false.
422433
*/
423
-int robot_restrict(const char *zTag){
434
+int robot_would_be_restricted(const char *zTag){
424435
if( robot.resultCache==KNOWN_NOT_ROBOT ) return 0;
425436
if( !robot_restrict_has_tag(zTag) ) return 0;
426437
if( !client_might_be_a_robot() ) return 0;
427438
if( robot_exception() ){
428439
robot.resultCache = KNOWN_NOT_ROBOT;
429440
return 0;
430441
}
431
-
432
- /* Generate the proof-of-work captcha */
433
- ask_for_proof_that_client_is_not_robot();
434442
return 1;
435443
}
444
+
445
+/*
446
+** Check to see if the page named in the argument is on the
447
+** robot-restrict list. If it is on the list and if the user
448
+** is might be a robot, then bring up a captcha to test to make
449
+** sure that client is not a robot.
450
+**
451
+** This routine returns true if a captcha was rendered and if subsequent
452
+** page generation should be aborted. It returns false if the page
453
+** should not be restricted and should be rendered normally.
454
+*/
455
+int robot_restrict(const char *zTag){
456
+ if( robot_would_be_restricted(zTag) ){
457
+ /* Generate the proof-of-work captcha */
458
+ ask_for_proof_that_client_is_not_robot();
459
+ return 1;
460
+ }else{
461
+ return 0;
462
+ }
463
+}
436464
437465
/*
438466
** Check to see if a robot is allowed to download a tarball, ZIP archive,
439467
** or SQL Archive for a particular check-in identified by the "rid"
440468
** argument. Return true to block the download. Return false to
441469
--- src/robot.c
+++ src/robot.c
@@ -325,11 +325,11 @@
325
326 /*
327 ** Return true if zTag matches one of the tags in the robot-restrict
328 ** setting.
329 */
330 int robot_restrict_has_tag(const char *zTag){
331 static const char *zGlob = 0;
332 if( zGlob==0 ){
333 zGlob = db_get("robot-restrict",robot_restrict_default());
334 if( zGlob==0 ) zGlob = "";
335 }
@@ -409,32 +409,60 @@
409 fossil_free(zRequest);
410 return bMatch;
411 }
412
413 /*
414 ** Check to see if the page named in the argument is on the
415 ** robot-restrict list. If it is on the list and if the user
416 ** is "nobody" then bring up a captcha to test to make sure that
417 ** client is not a robot.
 
 
 
 
 
 
 
 
 
 
418 **
419 ** This routine returns true if a captcha was rendered and if subsequent
420 ** page generation should be aborted. It returns false if the page
421 ** should not be restricted and should be rendered normally.
 
422 */
423 int robot_restrict(const char *zTag){
424 if( robot.resultCache==KNOWN_NOT_ROBOT ) return 0;
425 if( !robot_restrict_has_tag(zTag) ) return 0;
426 if( !client_might_be_a_robot() ) return 0;
427 if( robot_exception() ){
428 robot.resultCache = KNOWN_NOT_ROBOT;
429 return 0;
430 }
431
432 /* Generate the proof-of-work captcha */
433 ask_for_proof_that_client_is_not_robot();
434 return 1;
435 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
436
437 /*
438 ** Check to see if a robot is allowed to download a tarball, ZIP archive,
439 ** or SQL Archive for a particular check-in identified by the "rid"
440 ** argument. Return true to block the download. Return false to
441
--- src/robot.c
+++ src/robot.c
@@ -325,11 +325,11 @@
325
326 /*
327 ** Return true if zTag matches one of the tags in the robot-restrict
328 ** setting.
329 */
330 static int robot_restrict_has_tag(const char *zTag){
331 static const char *zGlob = 0;
332 if( zGlob==0 ){
333 zGlob = db_get("robot-restrict",robot_restrict_default());
334 if( zGlob==0 ) zGlob = "";
335 }
@@ -409,32 +409,60 @@
409 fossil_free(zRequest);
410 return bMatch;
411 }
412
413 /*
414 ** Return true if one or more of the conditions below are true.
415 ** Return false if all of the following are false:
416 **
417 ** * The zTag is on the robot-restrict list
418 **
419 ** * The client that submitted the HTTP request might be
420 ** a robot
421 **
422 ** * The Request URI does not match any of the exceptions
423 ** in the robot-exception setting.
424 **
425 ** In other words, return true if a call to robot_restrict() would
426 ** return true and false if a call to robot_restrict() would return
427 ** false.
428 **
429 ** The difference between this routine an robot_restrict() is that
430 ** this routine does not generate a proof-of-work captcha. This
431 ** routine does not change the HTTP reply in any way. It simply
432 ** returns true or false.
433 */
434 int robot_would_be_restricted(const char *zTag){
435 if( robot.resultCache==KNOWN_NOT_ROBOT ) return 0;
436 if( !robot_restrict_has_tag(zTag) ) return 0;
437 if( !client_might_be_a_robot() ) return 0;
438 if( robot_exception() ){
439 robot.resultCache = KNOWN_NOT_ROBOT;
440 return 0;
441 }
 
 
 
442 return 1;
443 }
444
445 /*
446 ** Check to see if the page named in the argument is on the
447 ** robot-restrict list. If it is on the list and if the user
448 ** is might be a robot, then bring up a captcha to test to make
449 ** sure that client is not a robot.
450 **
451 ** This routine returns true if a captcha was rendered and if subsequent
452 ** page generation should be aborted. It returns false if the page
453 ** should not be restricted and should be rendered normally.
454 */
455 int robot_restrict(const char *zTag){
456 if( robot_would_be_restricted(zTag) ){
457 /* Generate the proof-of-work captcha */
458 ask_for_proof_that_client_is_not_robot();
459 return 1;
460 }else{
461 return 0;
462 }
463 }
464
465 /*
466 ** Check to see if a robot is allowed to download a tarball, ZIP archive,
467 ** or SQL Archive for a particular check-in identified by the "rid"
468 ** argument. Return true to block the download. Return false to
469
+1 -2
--- src/tar.c
+++ src/tar.c
@@ -1156,12 +1156,11 @@
11561156
char *zBase;
11571157
int nUuid;
11581158
int rid;
11591159
login_check_credentials();
11601160
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
1161
- robot_restrict("zip");
1162
- robot_restrict("download");
1161
+ if( robot_restrict("zip") || robot_restrict("download") ) return;
11631162
11641163
zUuid = P("name");
11651164
if( zUuid==0
11661165
|| (nUuid = (int)strlen(zUuid))<6
11671166
|| !validate16(zUuid,-1)
11681167
--- src/tar.c
+++ src/tar.c
@@ -1156,12 +1156,11 @@
1156 char *zBase;
1157 int nUuid;
1158 int rid;
1159 login_check_credentials();
1160 if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
1161 robot_restrict("zip");
1162 robot_restrict("download");
1163
1164 zUuid = P("name");
1165 if( zUuid==0
1166 || (nUuid = (int)strlen(zUuid))<6
1167 || !validate16(zUuid,-1)
1168
--- src/tar.c
+++ src/tar.c
@@ -1156,12 +1156,11 @@
1156 char *zBase;
1157 int nUuid;
1158 int rid;
1159 login_check_credentials();
1160 if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
1161 if( robot_restrict("zip") || robot_restrict("download") ) return;
 
1162
1163 zUuid = P("name");
1164 if( zUuid==0
1165 || (nUuid = (int)strlen(zUuid))<6
1166 || !validate16(zUuid,-1)
1167

Keyboard Shortcuts

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