Fossil SCM
The auto-hyperlink setting now also applies of the fossil-client-ok cookie is present and valid.
Commit
fc8cefb6419d288e92e897f3b568b10fa52df05f14c6b5d2d9c2fa251a9385d4
Parent
35a09aea15efbe5…
3 files changed
+20
-2
+1
-1
+10
-8
+20
-2
| --- src/robot.c | ||
| +++ src/robot.c | ||
| @@ -90,10 +90,28 @@ | ||
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | robot.h1 = (h1 % 900000000) + 100000000; |
| 93 | 93 | robot.h2 = (h2 % 900000000) + 100000000; |
| 94 | 94 | } |
| 95 | + | |
| 96 | +/* | |
| 97 | +** Remember that the client is human, as evidenced by the presence of | |
| 98 | +** the fossil-client-ok or similar proof of work. Enable hyperlinks if | |
| 99 | +** auto-hyperlink is turned on. | |
| 100 | +*/ | |
| 101 | +static void remember_is_human(void){ | |
| 102 | + robot.resultCache = KNOWN_NOT_ROBOT; | |
| 103 | + if( g.perm.Hyperlink==0 ){ | |
| 104 | + int autoLink = db_get_int("auto-hyperlink",1); | |
| 105 | + if( autoLink==1 ){ | |
| 106 | + g.jsHref = 1; | |
| 107 | + g.perm.Hyperlink = 1; | |
| 108 | + }else if( autoLink==2 ){ | |
| 109 | + g.perm.Hyperlink = 1; | |
| 110 | + } | |
| 111 | + } | |
| 112 | +} | |
| 95 | 113 | |
| 96 | 114 | /* |
| 97 | 115 | ** Return true if the HTTP client has not demonstrated that it is |
| 98 | 116 | ** human interactive. Return false is the HTTP client might be |
| 99 | 117 | ** a non-interactive robot. |
| @@ -140,11 +158,11 @@ | ||
| 140 | 158 | z = P(ROBOT_COOKIE); |
| 141 | 159 | if( z ){ |
| 142 | 160 | unsigned h = atoi(z); |
| 143 | 161 | robot_pow_hash(); |
| 144 | 162 | if( (h==robot.h1 || h==robot.h2) && !cgi_is_qp(ROBOT_COOKIE) ){ |
| 145 | - robot.resultCache = KNOWN_NOT_ROBOT; | |
| 163 | + remember_is_human(); | |
| 146 | 164 | return 0; |
| 147 | 165 | } |
| 148 | 166 | } |
| 149 | 167 | |
| 150 | 168 | /* Condition 3: There is a "proof=VALUE" query parameter with a valid |
| @@ -155,11 +173,11 @@ | ||
| 155 | 173 | if( z ){ |
| 156 | 174 | unsigned h = atoi(z); |
| 157 | 175 | robot_pow_hash(); |
| 158 | 176 | if( h==robot.h1 || h==robot.h2 ){ |
| 159 | 177 | cgi_set_cookie(ROBOT_COOKIE,z,"/",900); |
| 160 | - robot.resultCache = KNOWN_NOT_ROBOT; | |
| 178 | + remember_is_human(); | |
| 161 | 179 | return 0; |
| 162 | 180 | } |
| 163 | 181 | cgi_tag_query_parameter("proof"); |
| 164 | 182 | } |
| 165 | 183 | |
| 166 | 184 |
| --- src/robot.c | |
| +++ src/robot.c | |
| @@ -90,10 +90,28 @@ | |
| 90 | } |
| 91 | } |
| 92 | robot.h1 = (h1 % 900000000) + 100000000; |
| 93 | robot.h2 = (h2 % 900000000) + 100000000; |
| 94 | } |
| 95 | |
| 96 | /* |
| 97 | ** Return true if the HTTP client has not demonstrated that it is |
| 98 | ** human interactive. Return false is the HTTP client might be |
| 99 | ** a non-interactive robot. |
| @@ -140,11 +158,11 @@ | |
| 140 | z = P(ROBOT_COOKIE); |
| 141 | if( z ){ |
| 142 | unsigned h = atoi(z); |
| 143 | robot_pow_hash(); |
| 144 | if( (h==robot.h1 || h==robot.h2) && !cgi_is_qp(ROBOT_COOKIE) ){ |
| 145 | robot.resultCache = KNOWN_NOT_ROBOT; |
| 146 | return 0; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /* Condition 3: There is a "proof=VALUE" query parameter with a valid |
| @@ -155,11 +173,11 @@ | |
| 155 | if( z ){ |
| 156 | unsigned h = atoi(z); |
| 157 | robot_pow_hash(); |
| 158 | if( h==robot.h1 || h==robot.h2 ){ |
| 159 | cgi_set_cookie(ROBOT_COOKIE,z,"/",900); |
| 160 | robot.resultCache = KNOWN_NOT_ROBOT; |
| 161 | return 0; |
| 162 | } |
| 163 | cgi_tag_query_parameter("proof"); |
| 164 | } |
| 165 | |
| 166 |
| --- src/robot.c | |
| +++ src/robot.c | |
| @@ -90,10 +90,28 @@ | |
| 90 | } |
| 91 | } |
| 92 | robot.h1 = (h1 % 900000000) + 100000000; |
| 93 | robot.h2 = (h2 % 900000000) + 100000000; |
| 94 | } |
| 95 | |
| 96 | /* |
| 97 | ** Remember that the client is human, as evidenced by the presence of |
| 98 | ** the fossil-client-ok or similar proof of work. Enable hyperlinks if |
| 99 | ** auto-hyperlink is turned on. |
| 100 | */ |
| 101 | static void remember_is_human(void){ |
| 102 | robot.resultCache = KNOWN_NOT_ROBOT; |
| 103 | if( g.perm.Hyperlink==0 ){ |
| 104 | int autoLink = db_get_int("auto-hyperlink",1); |
| 105 | if( autoLink==1 ){ |
| 106 | g.jsHref = 1; |
| 107 | g.perm.Hyperlink = 1; |
| 108 | }else if( autoLink==2 ){ |
| 109 | g.perm.Hyperlink = 1; |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | /* |
| 115 | ** Return true if the HTTP client has not demonstrated that it is |
| 116 | ** human interactive. Return false is the HTTP client might be |
| 117 | ** a non-interactive robot. |
| @@ -140,11 +158,11 @@ | |
| 158 | z = P(ROBOT_COOKIE); |
| 159 | if( z ){ |
| 160 | unsigned h = atoi(z); |
| 161 | robot_pow_hash(); |
| 162 | if( (h==robot.h1 || h==robot.h2) && !cgi_is_qp(ROBOT_COOKIE) ){ |
| 163 | remember_is_human(); |
| 164 | return 0; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /* Condition 3: There is a "proof=VALUE" query parameter with a valid |
| @@ -155,11 +173,11 @@ | |
| 173 | if( z ){ |
| 174 | unsigned h = atoi(z); |
| 175 | robot_pow_hash(); |
| 176 | if( h==robot.h1 || h==robot.h2 ){ |
| 177 | cgi_set_cookie(ROBOT_COOKIE,z,"/",900); |
| 178 | remember_is_human(); |
| 179 | return 0; |
| 180 | } |
| 181 | cgi_tag_query_parameter("proof"); |
| 182 | } |
| 183 | |
| 184 |
+1
-1
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -531,11 +531,11 @@ | ||
| 531 | 531 | @ Suggested remediation: |
| 532 | 532 | @ <ol type="a"> |
| 533 | 533 | @ <li>Remove the 'h' privilege from the |
| 534 | 534 | @ <a href="%R/setup_uedit?id=%d(nobodyId)">'nobody' user</a> so that |
| 535 | 535 | @ robots cannot see hyperlinks. |
| 536 | - @ <li>Activate <a href="%R/setup_robot">autohyperlink</a> so that | |
| 536 | + @ <li>Activate <a href="%R/setup_robot">auto-hyperlink</a> so that | |
| 537 | 537 | @ human readers can still see hyperlinks even if they are not logged in. |
| 538 | 538 | @ Set the delay to at least 50 milliseconds and require a mouse |
| 539 | 539 | @ event for maximum robot defense. |
| 540 | 540 | if( anonId>0 ){ |
| 541 | 541 | @ <li>Perhaps set the 'h' privilege on the |
| 542 | 542 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -531,11 +531,11 @@ | |
| 531 | @ Suggested remediation: |
| 532 | @ <ol type="a"> |
| 533 | @ <li>Remove the 'h' privilege from the |
| 534 | @ <a href="%R/setup_uedit?id=%d(nobodyId)">'nobody' user</a> so that |
| 535 | @ robots cannot see hyperlinks. |
| 536 | @ <li>Activate <a href="%R/setup_robot">autohyperlink</a> so that |
| 537 | @ human readers can still see hyperlinks even if they are not logged in. |
| 538 | @ Set the delay to at least 50 milliseconds and require a mouse |
| 539 | @ event for maximum robot defense. |
| 540 | if( anonId>0 ){ |
| 541 | @ <li>Perhaps set the 'h' privilege on the |
| 542 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -531,11 +531,11 @@ | |
| 531 | @ Suggested remediation: |
| 532 | @ <ol type="a"> |
| 533 | @ <li>Remove the 'h' privilege from the |
| 534 | @ <a href="%R/setup_uedit?id=%d(nobodyId)">'nobody' user</a> so that |
| 535 | @ robots cannot see hyperlinks. |
| 536 | @ <li>Activate <a href="%R/setup_robot">auto-hyperlink</a> so that |
| 537 | @ human readers can still see hyperlinks even if they are not logged in. |
| 538 | @ Set the delay to at least 50 milliseconds and require a mouse |
| 539 | @ event for maximum robot defense. |
| 540 | if( anonId>0 ){ |
| 541 | @ <li>Perhaps set the 'h' privilege on the |
| 542 |
+10
-8
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -418,15 +418,15 @@ | ||
| 418 | 418 | ** auto-hyperlink related robot defense settings. |
| 419 | 419 | */ |
| 420 | 420 | static void addAutoHyperlinkSettings(void){ |
| 421 | 421 | static const char *const azDefenseOpts[] = { |
| 422 | 422 | "0", "Off", |
| 423 | - "2", "UserAgent only", | |
| 424 | - "1", "UserAgent and Javascript", | |
| 423 | + "2", "HTTP Header Only", | |
| 424 | + "1", "HTTP Header And Javascript", | |
| 425 | 425 | }; |
| 426 | 426 | multiple_choice_attribute( |
| 427 | - "Enable hyperlinks base on User-Agent and/or Javascript", | |
| 427 | + "Enable hyperlinks base on HTTP Header and/or Javascript", | |
| 428 | 428 | "auto-hyperlink", "autohyperlink", "1", |
| 429 | 429 | count(azDefenseOpts)/2, azDefenseOpts); |
| 430 | 430 | @ <br> |
| 431 | 431 | entry_attribute("Delay in milliseconds before enabling hyperlinks", 5, |
| 432 | 432 | "auto-hyperlink-delay", "ah-delay", "50", 0); |
| @@ -435,16 +435,18 @@ | ||
| 435 | 435 | "auto-hyperlink-mouseover", "ahmo", 0, 0); |
| 436 | 436 | @ <p>Enable hyperlinks (the equivalent of the "h" permission) for all users, |
| 437 | 437 | @ including user "nobody" if the request appears to be from a human. |
| 438 | 438 | @ Disabling hyperlinks helps prevent robots from walking your site and |
| 439 | 439 | @ soaking up all your CPU and bandwidth. |
| 440 | - @ If this setting is "UserAgent only" (2) then the | |
| 441 | - @ UserAgent string is the only factor considered. If the value of this | |
| 442 | - @ setting is "UserAgent And Javascript" (1) then Javascript is added that | |
| 440 | + @ If this setting is "HTTP Header Only" (2) then only the HTTP header | |
| 441 | + @ content (including the UserAgent string and the fossil-client-ok cookie) | |
| 442 | + @ is considered when enabling hyperlinks. If the value of this | |
| 443 | + @ setting is "HTTP Header And Javascript" (1) then Javascript is added that | |
| 443 | 444 | @ runs after the page loads and fills in the href= values of <a> |
| 444 | - @ elements. In either case, <a> tags are not generated if the | |
| 445 | - @ UserAgent string indicates that the client is a robot. | |
| 445 | + @ elements. In either case, <a> tags are not generated unless the | |
| 446 | + @ UserAgent string and/or the fossil-client-ok cookie indicate that the | |
| 447 | + @ client is likely human. | |
| 446 | 448 | @ (Property: "auto-hyperlink")</p> |
| 447 | 449 | @ |
| 448 | 450 | @ <p>For maximum robot defense, "Delay" should be at least 50 milliseconds |
| 449 | 451 | @ and "require a mouse event" should be turned on. These values only come |
| 450 | 452 | @ into play when the main auto-hyperlink settings is 2 ("UserAgent and |
| 451 | 453 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -418,15 +418,15 @@ | |
| 418 | ** auto-hyperlink related robot defense settings. |
| 419 | */ |
| 420 | static void addAutoHyperlinkSettings(void){ |
| 421 | static const char *const azDefenseOpts[] = { |
| 422 | "0", "Off", |
| 423 | "2", "UserAgent only", |
| 424 | "1", "UserAgent and Javascript", |
| 425 | }; |
| 426 | multiple_choice_attribute( |
| 427 | "Enable hyperlinks base on User-Agent and/or Javascript", |
| 428 | "auto-hyperlink", "autohyperlink", "1", |
| 429 | count(azDefenseOpts)/2, azDefenseOpts); |
| 430 | @ <br> |
| 431 | entry_attribute("Delay in milliseconds before enabling hyperlinks", 5, |
| 432 | "auto-hyperlink-delay", "ah-delay", "50", 0); |
| @@ -435,16 +435,18 @@ | |
| 435 | "auto-hyperlink-mouseover", "ahmo", 0, 0); |
| 436 | @ <p>Enable hyperlinks (the equivalent of the "h" permission) for all users, |
| 437 | @ including user "nobody" if the request appears to be from a human. |
| 438 | @ Disabling hyperlinks helps prevent robots from walking your site and |
| 439 | @ soaking up all your CPU and bandwidth. |
| 440 | @ If this setting is "UserAgent only" (2) then the |
| 441 | @ UserAgent string is the only factor considered. If the value of this |
| 442 | @ setting is "UserAgent And Javascript" (1) then Javascript is added that |
| 443 | @ runs after the page loads and fills in the href= values of <a> |
| 444 | @ elements. In either case, <a> tags are not generated if the |
| 445 | @ UserAgent string indicates that the client is a robot. |
| 446 | @ (Property: "auto-hyperlink")</p> |
| 447 | @ |
| 448 | @ <p>For maximum robot defense, "Delay" should be at least 50 milliseconds |
| 449 | @ and "require a mouse event" should be turned on. These values only come |
| 450 | @ into play when the main auto-hyperlink settings is 2 ("UserAgent and |
| 451 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -418,15 +418,15 @@ | |
| 418 | ** auto-hyperlink related robot defense settings. |
| 419 | */ |
| 420 | static void addAutoHyperlinkSettings(void){ |
| 421 | static const char *const azDefenseOpts[] = { |
| 422 | "0", "Off", |
| 423 | "2", "HTTP Header Only", |
| 424 | "1", "HTTP Header And Javascript", |
| 425 | }; |
| 426 | multiple_choice_attribute( |
| 427 | "Enable hyperlinks base on HTTP Header and/or Javascript", |
| 428 | "auto-hyperlink", "autohyperlink", "1", |
| 429 | count(azDefenseOpts)/2, azDefenseOpts); |
| 430 | @ <br> |
| 431 | entry_attribute("Delay in milliseconds before enabling hyperlinks", 5, |
| 432 | "auto-hyperlink-delay", "ah-delay", "50", 0); |
| @@ -435,16 +435,18 @@ | |
| 435 | "auto-hyperlink-mouseover", "ahmo", 0, 0); |
| 436 | @ <p>Enable hyperlinks (the equivalent of the "h" permission) for all users, |
| 437 | @ including user "nobody" if the request appears to be from a human. |
| 438 | @ Disabling hyperlinks helps prevent robots from walking your site and |
| 439 | @ soaking up all your CPU and bandwidth. |
| 440 | @ If this setting is "HTTP Header Only" (2) then only the HTTP header |
| 441 | @ content (including the UserAgent string and the fossil-client-ok cookie) |
| 442 | @ is considered when enabling hyperlinks. If the value of this |
| 443 | @ setting is "HTTP Header And Javascript" (1) then Javascript is added that |
| 444 | @ runs after the page loads and fills in the href= values of <a> |
| 445 | @ elements. In either case, <a> tags are not generated unless the |
| 446 | @ UserAgent string and/or the fossil-client-ok cookie indicate that the |
| 447 | @ client is likely human. |
| 448 | @ (Property: "auto-hyperlink")</p> |
| 449 | @ |
| 450 | @ <p>For maximum robot defense, "Delay" should be at least 50 milliseconds |
| 451 | @ and "require a mouse event" should be turned on. These values only come |
| 452 | @ into play when the main auto-hyperlink settings is 2 ("UserAgent and |
| 453 |