Fossil SCM

Improved handling of exclude_robots(). Add the "isrobot" query parameter for testing.

drh 2016-05-31 01:16 trunk
Commit abcd5df2672bbde8badb3471c4be1f0edcc42c9c
--- src/browse.c
+++ src/browse.c
@@ -1021,10 +1021,11 @@
10211021
int showId = PB("showid");
10221022
Stmt q1, q2;
10231023
double baseTime;
10241024
login_check_credentials();
10251025
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1026
+ if( exclude_spiders() ) return;
10261027
zName = P("name");
10271028
if( zName==0 ) zName = "tip";
10281029
rid = symbolic_name_to_rid(zName, "ci");
10291030
if( rid==0 ){
10301031
fossil_fatal("not a valid check-in: %s", zName);
10311032
--- src/browse.c
+++ src/browse.c
@@ -1021,10 +1021,11 @@
1021 int showId = PB("showid");
1022 Stmt q1, q2;
1023 double baseTime;
1024 login_check_credentials();
1025 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
 
1026 zName = P("name");
1027 if( zName==0 ) zName = "tip";
1028 rid = symbolic_name_to_rid(zName, "ci");
1029 if( rid==0 ){
1030 fossil_fatal("not a valid check-in: %s", zName);
1031
--- src/browse.c
+++ src/browse.c
@@ -1021,10 +1021,11 @@
1021 int showId = PB("showid");
1022 Stmt q1, q2;
1023 double baseTime;
1024 login_check_credentials();
1025 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1026 if( exclude_spiders() ) return;
1027 zName = P("name");
1028 if( zName==0 ) zName = "tip";
1029 rid = symbolic_name_to_rid(zName, "ci");
1030 if( rid==0 ){
1031 fossil_fatal("not a valid check-in: %s", zName);
1032
+2 -2
--- src/captcha.c
+++ src/captcha.c
@@ -578,11 +578,11 @@
578578
** be a spider. If the agent is not a spider, then return 0 without doing
579579
** anything. But if the user agent appears to be a spider, offer
580580
** a captcha challenge to allow the user agent to prove that it is human
581581
** and return non-zero.
582582
*/
583
-int exclude_spiders(const char *zPage){
583
+int exclude_spiders(void){
584584
const char *zCookieValue;
585585
char *zCookieName;
586586
if( g.isHuman ) return 0;
587587
#if 0
588588
{
@@ -600,13 +600,13 @@
600600
return 0;
601601
}
602602
603603
/* This appears to be a spider. Offer the captcha */
604604
style_header("Verification");
605
- form_begin(0, "%s", zPage);
605
+ form_begin(0, "%s", g.zPath);
606606
cgi_query_parameters_to_hidden();
607607
@ <p>Please demonstrate that you are human, not a spider or robot</p>
608608
captcha_generate(1);
609609
@ </form>
610610
style_footer();
611611
return 1;
612612
}
613613
--- src/captcha.c
+++ src/captcha.c
@@ -578,11 +578,11 @@
578 ** be a spider. If the agent is not a spider, then return 0 without doing
579 ** anything. But if the user agent appears to be a spider, offer
580 ** a captcha challenge to allow the user agent to prove that it is human
581 ** and return non-zero.
582 */
583 int exclude_spiders(const char *zPage){
584 const char *zCookieValue;
585 char *zCookieName;
586 if( g.isHuman ) return 0;
587 #if 0
588 {
@@ -600,13 +600,13 @@
600 return 0;
601 }
602
603 /* This appears to be a spider. Offer the captcha */
604 style_header("Verification");
605 form_begin(0, "%s", zPage);
606 cgi_query_parameters_to_hidden();
607 @ <p>Please demonstrate that you are human, not a spider or robot</p>
608 captcha_generate(1);
609 @ </form>
610 style_footer();
611 return 1;
612 }
613
--- src/captcha.c
+++ src/captcha.c
@@ -578,11 +578,11 @@
578 ** be a spider. If the agent is not a spider, then return 0 without doing
579 ** anything. But if the user agent appears to be a spider, offer
580 ** a captcha challenge to allow the user agent to prove that it is human
581 ** and return non-zero.
582 */
583 int exclude_spiders(void){
584 const char *zCookieValue;
585 char *zCookieName;
586 if( g.isHuman ) return 0;
587 #if 0
588 {
@@ -600,13 +600,13 @@
600 return 0;
601 }
602
603 /* This appears to be a spider. Offer the captcha */
604 style_header("Verification");
605 form_begin(0, "%s", g.zPath);
606 cgi_query_parameters_to_hidden();
607 @ <p>Please demonstrate that you are human, not a spider or robot</p>
608 captcha_generate(1);
609 @ </form>
610 style_footer();
611 return 1;
612 }
613
+1 -1
--- src/diff.c
+++ src/diff.c
@@ -2281,11 +2281,11 @@
22812281
22822282
/* Gather query parameters */
22832283
showLog = atoi(PD("log","1"));
22842284
login_check_credentials();
22852285
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
2286
- if( exclude_spiders("annotate") ) return;
2286
+ if( exclude_spiders() ) return;
22872287
load_control();
22882288
mid = name_to_typed_rid(PD("checkin","0"),"ci");
22892289
zFilename = P("filename");
22902290
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
22912291
if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
22922292
--- src/diff.c
+++ src/diff.c
@@ -2281,11 +2281,11 @@
2281
2282 /* Gather query parameters */
2283 showLog = atoi(PD("log","1"));
2284 login_check_credentials();
2285 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
2286 if( exclude_spiders("annotate") ) return;
2287 load_control();
2288 mid = name_to_typed_rid(PD("checkin","0"),"ci");
2289 zFilename = P("filename");
2290 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
2291 if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
2292
--- src/diff.c
+++ src/diff.c
@@ -2281,11 +2281,11 @@
2281
2282 /* Gather query parameters */
2283 showLog = atoi(PD("log","1"));
2284 login_check_credentials();
2285 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
2286 if( exclude_spiders() ) return;
2287 load_control();
2288 mid = name_to_typed_rid(PD("checkin","0"),"ci");
2289 zFilename = P("filename");
2290 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
2291 if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
2292
+7 -1
--- src/login.c
+++ src/login.c
@@ -995,11 +995,17 @@
995995
*/
996996
g.userUid = uid;
997997
if( fossil_strcmp(g.zLogin,"nobody")==0 ){
998998
g.zLogin = 0;
999999
}
1000
- g.isHuman = g.zLogin==0 ? isHuman(P("HTTP_USER_AGENT")) : 1;
1000
+ if( PB("isrobot") ){
1001
+ g.isHuman = 0;
1002
+ }else if( g.zLogin==0 ){
1003
+ g.isHuman = isHuman(P("HTTP_USER_AGENT"));
1004
+ }else{
1005
+ g.isHuman = 1;
1006
+ }
10011007
10021008
/* Set the capabilities */
10031009
login_replace_capabilities(zCap, 0);
10041010
login_set_anon_nobody_capabilities();
10051011
10061012
--- src/login.c
+++ src/login.c
@@ -995,11 +995,17 @@
995 */
996 g.userUid = uid;
997 if( fossil_strcmp(g.zLogin,"nobody")==0 ){
998 g.zLogin = 0;
999 }
1000 g.isHuman = g.zLogin==0 ? isHuman(P("HTTP_USER_AGENT")) : 1;
 
 
 
 
 
 
1001
1002 /* Set the capabilities */
1003 login_replace_capabilities(zCap, 0);
1004 login_set_anon_nobody_capabilities();
1005
1006
--- src/login.c
+++ src/login.c
@@ -995,11 +995,17 @@
995 */
996 g.userUid = uid;
997 if( fossil_strcmp(g.zLogin,"nobody")==0 ){
998 g.zLogin = 0;
999 }
1000 if( PB("isrobot") ){
1001 g.isHuman = 0;
1002 }else if( g.zLogin==0 ){
1003 g.isHuman = isHuman(P("HTTP_USER_AGENT"));
1004 }else{
1005 g.isHuman = 1;
1006 }
1007
1008 /* Set the capabilities */
1009 login_replace_capabilities(zCap, 0);
1010 login_set_anon_nobody_capabilities();
1011
1012

Keyboard Shortcuts

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