django-simple-captcha icon indicating copy to clipboard operation
django-simple-captcha copied to clipboard

Weird characters on Debian

Open osam opened this issue 12 years ago • 5 comments

It working correctly on my development machine but when I deployed the app I got these weird characters from nowhere, as you can see from this image:

Screen Shot 2013-01-17 at 2 47 55 AM

This is my PIL log:

--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.7.3 (default, Dec  2 2012, 14:33:47)
              [GCC 4.4.5]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------

Your help would be appreciated.

osam avatar Jan 17 '13 07:01 osam

Interesting.

Could it be you are using a different font set between dev and production? Also, what is the character encoding of either installations?

mbi avatar Jan 17 '13 08:01 mbi

Could it be you are using a different font set between dev and production?

No but when I faced the problem I tried to change the default font and that didn't solve the problem.

what is the character encoding of either installations?

Character encoding of what exactly?

osam avatar Jan 17 '13 21:01 osam

Sorry, the default text encoding, i.e. the output of:

>>> import sys
>>> sys.getdefaultencoding()

mbi avatar Jan 18 '13 09:01 mbi

Also, are you using a custom generator, or is that the default simplemath generator? See, I think the weird chars before each valid char are due to the fact that PIL (or freetype2) receives an Unicode string (or other encoded multi-byte chars) and misinterprets those as multiple chars.

If this is indeed a custom generator, could you please try and force the returned bits to string?

mbi avatar Jan 18 '13 14:01 mbi

~$ python Python 2.7.3 (default, Dec 2 2012, 14:33:47) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import sys sys.getdefaultencoding() 'ascii'

are you using a custom generator, or is that the default simplemath generator?

The default but it has nothing to do with the math generator per se I think. I am also getting the rectangles with the letter based captchas. I fixed it temporarily by removing the spaces from ' %s ': https://github.com/mbi/django-simple-captcha/blob/master/captcha/views.py#L52-L54

I had to switch to the letter mode because operators + / * - where also showing as rectangles.

osam avatar Jan 19 '13 00:01 osam