Fossil SCM
Improvements to comments on recently added CAPTCHA code.
Commit
64231a679d0e1da770004c36a47f78fca4f2ac78
Parent
82b8587a502f32e…
1 file changed
+16
-4
+16
-4
| --- src/captcha.c | ||
| +++ src/captcha.c | ||
| @@ -440,23 +440,32 @@ | ||
| 440 | 440 | zRes[8] = 0; |
| 441 | 441 | return zRes; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /* |
| 445 | -** Return true if a CAPTCHA is required. | |
| 445 | +** Return true if a CAPTCHA is required for editing wiki or tickets or for | |
| 446 | +** adding attachments. | |
| 447 | +** | |
| 448 | +** A CAPTCHA is required in those cases if the user is not logged in (if they | |
| 449 | +** are user "nobody") and if the "require-captcha" setting is true. The | |
| 450 | +** "require-captcha" setting is controlled on the Admin/Access page. It | |
| 451 | +** defaults to true. | |
| 446 | 452 | */ |
| 447 | 453 | int captcha_needed(void){ |
| 448 | 454 | if( g.zLogin!=0 ) return 0; |
| 449 | 455 | return db_get_boolean("require-captcha", 1); |
| 450 | 456 | } |
| 451 | 457 | |
| 452 | 458 | /* |
| 453 | 459 | ** If a captcha is required but the correct captcha code is not supplied |
| 454 | -** in the query parameters, then return false (0). | |
| 460 | +** in the query parameters, then return false (0). | |
| 455 | 461 | ** |
| 456 | 462 | ** If no captcha is required or if the correct captcha is supplied, return |
| 457 | 463 | ** true (non-zero). |
| 464 | +** | |
| 465 | +** The query parameters examined are "captchaseed" for the seed value and | |
| 466 | +** "captcha" for text that the user types in response to the captcha prompt. | |
| 458 | 467 | */ |
| 459 | 468 | int captcha_is_correct(void){ |
| 460 | 469 | const char *zSeed; |
| 461 | 470 | const char *zEntered; |
| 462 | 471 | const char *zDecode; |
| @@ -471,12 +480,15 @@ | ||
| 471 | 480 | if( strcmp(zDecode,zEntered)!=0 ) return 0; |
| 472 | 481 | return 1; |
| 473 | 482 | } |
| 474 | 483 | |
| 475 | 484 | /* |
| 476 | -** Generate a new CAPTCHA seed. Write it as a hidden variable named | |
| 477 | -** "captchaseed". Then return the rendered captcha text. | |
| 485 | +** Generate a captcha display together with the necessary hidden parameter | |
| 486 | +** for the seed and the entry box into which the user will type the text of | |
| 487 | +** the captcha. This is typically done at the very bottom of a form. | |
| 488 | +** | |
| 489 | +** This routine is a no-op if no captcha is required. | |
| 478 | 490 | */ |
| 479 | 491 | void captcha_generate(void){ |
| 480 | 492 | unsigned int uSeed; |
| 481 | 493 | const char *zDecoded; |
| 482 | 494 | char *zCaptcha; |
| 483 | 495 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -440,23 +440,32 @@ | |
| 440 | zRes[8] = 0; |
| 441 | return zRes; |
| 442 | } |
| 443 | |
| 444 | /* |
| 445 | ** Return true if a CAPTCHA is required. |
| 446 | */ |
| 447 | int captcha_needed(void){ |
| 448 | if( g.zLogin!=0 ) return 0; |
| 449 | return db_get_boolean("require-captcha", 1); |
| 450 | } |
| 451 | |
| 452 | /* |
| 453 | ** If a captcha is required but the correct captcha code is not supplied |
| 454 | ** in the query parameters, then return false (0). |
| 455 | ** |
| 456 | ** If no captcha is required or if the correct captcha is supplied, return |
| 457 | ** true (non-zero). |
| 458 | */ |
| 459 | int captcha_is_correct(void){ |
| 460 | const char *zSeed; |
| 461 | const char *zEntered; |
| 462 | const char *zDecode; |
| @@ -471,12 +480,15 @@ | |
| 471 | if( strcmp(zDecode,zEntered)!=0 ) return 0; |
| 472 | return 1; |
| 473 | } |
| 474 | |
| 475 | /* |
| 476 | ** Generate a new CAPTCHA seed. Write it as a hidden variable named |
| 477 | ** "captchaseed". Then return the rendered captcha text. |
| 478 | */ |
| 479 | void captcha_generate(void){ |
| 480 | unsigned int uSeed; |
| 481 | const char *zDecoded; |
| 482 | char *zCaptcha; |
| 483 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -440,23 +440,32 @@ | |
| 440 | zRes[8] = 0; |
| 441 | return zRes; |
| 442 | } |
| 443 | |
| 444 | /* |
| 445 | ** Return true if a CAPTCHA is required for editing wiki or tickets or for |
| 446 | ** adding attachments. |
| 447 | ** |
| 448 | ** A CAPTCHA is required in those cases if the user is not logged in (if they |
| 449 | ** are user "nobody") and if the "require-captcha" setting is true. The |
| 450 | ** "require-captcha" setting is controlled on the Admin/Access page. It |
| 451 | ** defaults to true. |
| 452 | */ |
| 453 | int captcha_needed(void){ |
| 454 | if( g.zLogin!=0 ) return 0; |
| 455 | return db_get_boolean("require-captcha", 1); |
| 456 | } |
| 457 | |
| 458 | /* |
| 459 | ** If a captcha is required but the correct captcha code is not supplied |
| 460 | ** in the query parameters, then return false (0). |
| 461 | ** |
| 462 | ** If no captcha is required or if the correct captcha is supplied, return |
| 463 | ** true (non-zero). |
| 464 | ** |
| 465 | ** The query parameters examined are "captchaseed" for the seed value and |
| 466 | ** "captcha" for text that the user types in response to the captcha prompt. |
| 467 | */ |
| 468 | int captcha_is_correct(void){ |
| 469 | const char *zSeed; |
| 470 | const char *zEntered; |
| 471 | const char *zDecode; |
| @@ -471,12 +480,15 @@ | |
| 480 | if( strcmp(zDecode,zEntered)!=0 ) return 0; |
| 481 | return 1; |
| 482 | } |
| 483 | |
| 484 | /* |
| 485 | ** Generate a captcha display together with the necessary hidden parameter |
| 486 | ** for the seed and the entry box into which the user will type the text of |
| 487 | ** the captcha. This is typically done at the very bottom of a form. |
| 488 | ** |
| 489 | ** This routine is a no-op if no captcha is required. |
| 490 | */ |
| 491 | void captcha_generate(void){ |
| 492 | unsigned int uSeed; |
| 493 | const char *zDecoded; |
| 494 | char *zCaptcha; |
| 495 |