Closed GoogleCodeExporter closed 9 years ago
wow. finally a real bug report and a patch (vs. the crap other people submit).
you rock. =)
i'll get that fixed in svn as soon as i have a chance.
Original comment by latch...@gmail.com
on 9 Feb 2009 at 9:52
Hey, thanks for answering so fast. I think it is a nice feature, keep up the
good
work :-)
Original comment by jchoffm...@gmail.com
on 10 Feb 2009 at 9:15
Original comment by latch...@gmail.com
on 17 Feb 2009 at 12:57
Original comment by latch...@gmail.com
on 16 Nov 2010 at 8:33
This issue was closed by revision r117.
Original comment by whiche...@gmail.com
on 20 Nov 2010 at 7:28
What steps will reproduce the problem?
1. Get kaptcha up and running
2. Configure a simple textproducer char string for the DefaultTextCreator,
i.e. use the following parameters:
kaptcha.textproducer.char.string="abcefghijklmnopqrstuvwxyz"
kaptcha.textproducer.char.length=5
What is the expected output? What do you see instead?
Captcha image containing a random sequence of the configured characters.
Instead, only first 5 characters appear. This is due to previous bug fix on
version 2.3
What version of the product are you using? On what operating system?
kaptcha-2.3.1.jar on Windows XP (will happen on any environment as the
error is in the source code, see below)
Please provide any additional information below.
Take a look at the getText method:
int length = getConfig().getTextProducerCharLength();
char[] chars = getConfig().getTextProducerCharString();
Random rand = new Random();
StringBuffer text = new StringBuffer();
for (int i = 0; i < length; i++)
{
text.append(chars[rand.nextInt(length)]);
}
return text.toString();
This will only produce the first "length" (5) characters.
The correct version is to change line 25 adding "chars.length" instead of
"length":
int length = getConfig().getTextProducerCharLength();
char[] chars = getConfig().getTextProducerCharString();
Random rand = new Random();
StringBuffer text = new StringBuffer();
for (int i = 0; i < length; i++)
{
text.append(chars[rand.nextInt(chars.length)]);
}
return text.toString();
Attached is a patch to fix this. It simply changes line 25.
Original comment by fkim...@gmail.com
on 25 Nov 2010 at 1:05
Attachments:
ok, i've committed this fix.
Original comment by latch...@gmail.com
on 5 Dec 2010 at 11:37
Original issue reported on code.google.com by
jchoffm...@gmail.com
on 9 Feb 2009 at 5:36Attachments: