Fossil SCM
Improved handling of exclude_robots(). Add the "isrobot" query parameter for testing.
Commit
abcd5df2672bbde8badb3471c4be1f0edcc42c9c
Parent
d685096f99a9779…
4 files changed
+1
+2
-2
+1
-1
+7
-1
+1
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -1021,10 +1021,11 @@ | ||
| 1021 | 1021 | int showId = PB("showid"); |
| 1022 | 1022 | Stmt q1, q2; |
| 1023 | 1023 | double baseTime; |
| 1024 | 1024 | login_check_credentials(); |
| 1025 | 1025 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 1026 | + if( exclude_spiders() ) return; | |
| 1026 | 1027 | zName = P("name"); |
| 1027 | 1028 | if( zName==0 ) zName = "tip"; |
| 1028 | 1029 | rid = symbolic_name_to_rid(zName, "ci"); |
| 1029 | 1030 | if( rid==0 ){ |
| 1030 | 1031 | fossil_fatal("not a valid check-in: %s", zName); |
| 1031 | 1032 |
| --- 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 @@ | ||
| 578 | 578 | ** be a spider. If the agent is not a spider, then return 0 without doing |
| 579 | 579 | ** anything. But if the user agent appears to be a spider, offer |
| 580 | 580 | ** a captcha challenge to allow the user agent to prove that it is human |
| 581 | 581 | ** and return non-zero. |
| 582 | 582 | */ |
| 583 | -int exclude_spiders(const char *zPage){ | |
| 583 | +int exclude_spiders(void){ | |
| 584 | 584 | const char *zCookieValue; |
| 585 | 585 | char *zCookieName; |
| 586 | 586 | if( g.isHuman ) return 0; |
| 587 | 587 | #if 0 |
| 588 | 588 | { |
| @@ -600,13 +600,13 @@ | ||
| 600 | 600 | return 0; |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /* This appears to be a spider. Offer the captcha */ |
| 604 | 604 | style_header("Verification"); |
| 605 | - form_begin(0, "%s", zPage); | |
| 605 | + form_begin(0, "%s", g.zPath); | |
| 606 | 606 | cgi_query_parameters_to_hidden(); |
| 607 | 607 | @ <p>Please demonstrate that you are human, not a spider or robot</p> |
| 608 | 608 | captcha_generate(1); |
| 609 | 609 | @ </form> |
| 610 | 610 | style_footer(); |
| 611 | 611 | return 1; |
| 612 | 612 | } |
| 613 | 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(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 @@ | ||
| 2281 | 2281 | |
| 2282 | 2282 | /* Gather query parameters */ |
| 2283 | 2283 | showLog = atoi(PD("log","1")); |
| 2284 | 2284 | login_check_credentials(); |
| 2285 | 2285 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 2286 | - if( exclude_spiders("annotate") ) return; | |
| 2286 | + if( exclude_spiders() ) return; | |
| 2287 | 2287 | load_control(); |
| 2288 | 2288 | mid = name_to_typed_rid(PD("checkin","0"),"ci"); |
| 2289 | 2289 | zFilename = P("filename"); |
| 2290 | 2290 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| 2291 | 2291 | if( mid==0 || fnid==0 ){ fossil_redirect_home(); } |
| 2292 | 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("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 @@ | ||
| 995 | 995 | */ |
| 996 | 996 | g.userUid = uid; |
| 997 | 997 | if( fossil_strcmp(g.zLogin,"nobody")==0 ){ |
| 998 | 998 | g.zLogin = 0; |
| 999 | 999 | } |
| 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 | + } | |
| 1001 | 1007 | |
| 1002 | 1008 | /* Set the capabilities */ |
| 1003 | 1009 | login_replace_capabilities(zCap, 0); |
| 1004 | 1010 | login_set_anon_nobody_capabilities(); |
| 1005 | 1011 | |
| 1006 | 1012 |
| --- 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 |