# ########
# Captcha
# ########
captcha.registration = true
captcha.posts = true
captcha.ignore.case = true
captcha.width = 250
captcha.height = 75
captcha.min.words = 4
captcha.max.words = 6
captcha.min.font.size = 25
captcha.max.font.size = 35
captcha.ignore.case = false
andowson wrote:Please provide your system configuration for more information. Thanks~
boolean needCaptcha = SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS)
&& request.getSessionContext().getAttribute(ConfigKeys.REQUEST_IGNORE_CAPTCHA) == null;
if (needCaptcha && !us.validateCaptchaResponse(this.request.getParameter("captcha_anwser"))) {
this.context.put("post", post);
this.context.put("start", this.request.getParameter("start"));
this.context.put("error", I18n.getMessage("CaptchaResponseFails"));
this.insert();
return;
}
public boolean validateCaptchaResponse(String origUserResponse)
{
String userResponse = origUserResponse;
if ((SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_REGISTRATION)
|| SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS))
&& this.imageCaptcha != null) {
if (SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_IGNORE_CASE)) {
userResponse = userResponse.toLowerCase(Locale.US);
}
final boolean result = this.imageCaptcha.validateResponse(userResponse).booleanValue();
this.destroyCaptcha();
return result;
}
return true;
}
SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_REGISTRATION)
|| SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS))
&& this.imageCaptcha != null
public boolean validateCaptchaResponse(String origUserResponse)
{
String userResponse = origUserResponse;
if ((SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_REGISTRATION)
|| SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS))
&& this.imageCaptcha != null) {
if (SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_IGNORE_CASE)) {
userResponse = userResponse.toLowerCase(Locale.US);
}
final boolean result = this.imageCaptcha.validateResponse(userResponse).booleanValue();
this.destroyCaptcha();
return result;
}
return false;
}
andowson wrote:I found that this issue can be reproduced at the first time Java VM starts to load the Captcha engine.
When the Captcha engine is not ready, the imageCaptcha will return null.
A quick fix is to replace the last return statement from return true to return false.
public boolean validateCaptchaResponse(String origUserResponse)
{
String userResponse = origUserResponse;
if ((SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_REGISTRATION)
|| SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS))
&& this.imageCaptcha != null) {
if (SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_IGNORE_CASE)) {
userResponse = userResponse.toLowerCase(Locale.US);
}
final boolean result = this.imageCaptcha.validateResponse(userResponse).booleanValue();
this.destroyCaptcha();
return result;
}
return false;
}
private ImageCaptcha testImageCaptcha(){
if(this.imageCaptcha == null)
this.imageCaptcha = Captcha.getInstance().getNextImageCaptcha();
return this.imageCaptcha;
}
andowson wrote:Please provide your system environment for more information. Thanks~
andowson wrote:Hi, I've commit the fix as r224.
JForum will disable the submit button until the captcha image is fully loaded.
Please check out and test if this works.
-Djava.awt.headless=true