kasunkv / recaptcha

Automatically exported from code.google.com/p/recaptcha
0 stars 0 forks source link

Wordpress plugin (2.7) messes up UTF8 text under Firefox when not solving CAPTCHA correctly #8

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write a comment with UTF8 chars under Firefox
2. Submit without solving CAPTCHA
3. When the comment you wrote is re-inserted into the comment field, you
see question marks instead of UTF8 chars

What is the expected output? What do you see instead?

The expected output is the same text that was previously entered.

What version of the product are you using? On what operating system?

2.7, Firefox2 on WinXP (Client), Apache2.2 and PHP5 (Server).

The problem seems to stem from PHP urlencoding UTF8 strings differently
than JS decodes them. So I just tried to escape "dangerous" characters
without touching UTF8 characters.

I managed to solve the problem by replacing line 144 of recaptcha.php from
this:
var _recaptcha_wordpress_savedcomment =  '" .
rawurlencode(utf8_decode($comment->comment_content)) ."';

to this:
var _recaptcha_wordpress_savedcomment =  '" .
preg_replace('/([\<\>\/\(\)\+\;\'\"])/e', '\'%\'.dechex(ord(\'$1\'))',
$comment->comment_content) ."';

Credit should go to Keith Devens (
http://keithdevens.com/weblog/archive/2005/Nov/22/uriescape ) from whom I
got the idea. Tried it on IE6 and Ff2, seems to work...

Original issue reported on code.google.com by plast...@gmail.com on 2 Jan 2008 at 2:38

GoogleCodeExporter commented 8 years ago
Hello? :)
This has been open for quite a while now...

Original comment by plast...@gmail.com on 9 Jan 2008 at 1:08

GoogleCodeExporter commented 8 years ago
Sorry. Your fix has been added, though it won't appear until version 2.8.

Original comment by jorgepbl...@gmail.com on 23 Feb 2008 at 8:07

GoogleCodeExporter commented 8 years ago
Thank you!

Original comment by plast...@gmail.com on 23 Feb 2008 at 8:19