GNOME Bugzilla – Bug 309915
mixes utf-8 and filename encoding strings!
Last modified: 2005-08-17 21:02:01 UTC
In ps/ps-document.c check_filecompressed() gs->filename is used for opening the file, which means it's in filename encoding. But in the error case, it's used in the UTF-8 error message: g_snprintf (buf, 1024, _("Error while decompressing file %s:\n"), gs->gs_filename); Printing the message into a fixed-size (1024) buffer isn't UTF-8 safe either.
Same problem in document_load().
Created attachment 49940 [details] [review] Patch This patch fixes it in the ps backend. For pdfs I'm going to send a patch to poppler list
The patch is okay, but it doesn't fix the whole problem. The problem is still there in check_file_compressed, and document_load.
Created attachment 49970 [details] [review] Updated patch Ok, here is an updated patch
Thanks for the patch! + utf8 = g_locale_to_utf8 (gs->gs_filename, -1, NULL, NULL, NULL); g_snprintf (buf, 1024, _("Error while decompressing file %s:\n"), - gs->gs_filename); + utf8 != NULL ? utf8 : gs->gs_filename); + g_free (utf8); [...] + utf8 = g_locale_to_utf8 (fname, -1, NULL, NULL, NULL); + g_snprintf (buf, 1024, _("Cannot open file %s.\n"), + utf8 != NULL ? utf8 : fname); + g_free (utf8); This still has the problem: - mixed UTF-8 and filename encoding when it couldn't be converted; I think it should just say "invalid filename" or so, then - prints UTF-8 into a fixed size buffer which can make it invalid UTF-8 (chopping a multi-byte character in the middle at the end of the buffer)
Created attachment 50077 [details] [review] Another update Here is another update. The patch breaks now the string freeze.
> Here is another update. The patch breaks now the string freeze. Luckily we only have string announce period, not freeze yet :) There's still 4 instances of g_snprintf into a fixed-size buffer + g_snprintf (buf, 1024, _("Error while decompressing file %s:\n"), utf8); which should be replaced with a g_strdup_printf.
Created attachment 50137 [details] [review] Yet another update Ok to commit?
Looks good to me. Marco?
Comment on attachment 50137 [details] [review] Yet another update + utf8 = g_locale_to_utf8 (gs->gs_filename, -1, NULL, NULL, NULL); + + if (utf8) { + msg = g_strdup_printf (_("Error while decompressing file %s:\n"), utf8); + g_free (utf8); + } else { I prefer to free utf8 out of the if (it's null safe anyway). It's more readable. There are a few of this in the patch... Please commit asap, we need a release today to fix a building problem and it would be good to have it in.
2005-08-16 Carlos Garcia Campos <carlosgc@gnome.org> * ps/ps-document.c: convert filename to utf8 when there is an error loading document. Fixes #309915
Carlos, did you announce the string change while committing?
Actually, string freeze occurred before it was committed, meaning that it needs approval from i18n or needs to be backed out...
I've just fixed it. It doesn't break the freeze right now.
Cool, thanks. However, while there aren't any string changes anymore for translated strings, you did mark a string for translation that wasn't before ("Failed to load document '%s'", in addition to dropping the \n at the end of the string). This doesn't need approval (see http://mail.gnome.org/archives/desktop-devel-list/2005-February/msg00092.html), but gnome-i18n still needs to be notified of this specific string being marked for translation.
I've just announced it. Thank you very much Elijah