love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
5.2k stars 404 forks source link

Exception handling on UTF-8 decoding #249

Closed slime73 closed 13 years ago

slime73 commented 13 years ago

Original report by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


The UTF-8 library throws exceptions on invalid strings (and possibly other things) that don't get caught yet.

Attached a .love with the UTF-8 stress test. Notice that there's a null character in the text before the malformed sequences and LÖVE stops decoding. Press 0 to replace it.

slime73 commented 13 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


I might note that it doesn't //handle// it, but at least it fails gracefully now.

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


font:getWrap(string, width) also uses UTF-8 and has no exception handling yet. \\ https://bitbucket.org/rude/love/src/3a3111c0c6cb/src/modules/graphics/opengl/Font.cpp#cl-247 \\ Uhm, there might be even more UTF-8 iterators.

slime73 commented 13 years ago

Original comment by Lap (Bitbucket: Lap, GitHub: Lap).


Trying to require a file that does not exist now gives a deceptive error message instead of a "file not found" type message.

"decoding error: invalid UTF-8"
graphics.lua:1275: decoding errorl: invalid UTF-8
slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


The following makes the UTF-8 library throw invalid_code_point that doesn't get caught yet. \\

#!lua
str = "\113\233\129\139\227\134\146\236\188\129\233\151\134\231\171"..
"\161\229\166\187\238\149\145\237\138\157\235\188\156\226\178\169\237\175\153"
love.graphics.print(str, 10, 10)
slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


It doesn't get terminated anymore.

The "unknown exception" error is not helpful, though. Remember to fix this on the way to world domination.

slime73 commented 13 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Sigh..

slime73 commented 13 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Can we finally put this one to rest?