darktable-org/darktable — pull request #304 by jktjkt (2013-09-08 18:23:32+00:00)
Title: Allow valid UTF-8 sequences in the metadata editor

The offending code was added in response to bug #8744. GTK is documented to
expect valid UTF-8 sequences as input, and is free to crash on invalid input
otherwise. The original fix, however, simply replaced non-ASCII characters with
dots which is clearly not accept able for someone named like me. This change
instead skips this replacement when the string is a valid UTF-8 sequence.

The g_utf8_validate must be invoked without the size being passed. If we pass
around the expected size, then this function fails because it hits the first
NUL byte, a terminator, prior to hitting the length limit, and this is
documented to return false.