After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 309915 - mixes utf-8 and filename encoding strings!
mixes utf-8 and filename encoding strings!
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
git master
Other Linux
: High critical
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks: 312019
 
 
Reported: 2005-07-09 21:27 UTC by Christian Persch
Modified: 2005-08-17 21:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (1.21 KB, patch)
2005-07-29 14:22 UTC, Carlos Garcia Campos
none Details | Review
Updated patch (2.22 KB, patch)
2005-07-30 10:47 UTC, Carlos Garcia Campos
needs-work Details | Review
Another update (2.60 KB, patch)
2005-08-01 16:59 UTC, Carlos Garcia Campos
none Details | Review
Yet another update (3.74 KB, patch)
2005-08-02 15:51 UTC, Carlos Garcia Campos
committed Details | Review

Description Christian Persch 2005-07-09 21:27:40 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.
Comment 1 Christian Persch 2005-07-09 21:31:41 UTC
Same problem in document_load().
Comment 2 Carlos Garcia Campos 2005-07-29 14:22:35 UTC
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
Comment 3 Christian Persch 2005-07-29 15:06:57 UTC
The patch is okay, but it doesn't fix the whole problem. The problem is still
there in check_file_compressed, and document_load.
Comment 4 Carlos Garcia Campos 2005-07-30 10:47:03 UTC
Created attachment 49970 [details] [review]
Updated patch

Ok, here is an updated patch
Comment 5 Christian Persch 2005-07-30 11:58:13 UTC
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)
Comment 6 Carlos Garcia Campos 2005-08-01 16:59:49 UTC
Created attachment 50077 [details] [review]
Another update

Here is another update. The patch breaks now the string freeze.
Comment 7 Christian Persch 2005-08-01 22:16:11 UTC
> 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.
Comment 8 Carlos Garcia Campos 2005-08-02 15:51:23 UTC
Created attachment 50137 [details] [review]
Yet another update

Ok to commit?
Comment 9 Christian Persch 2005-08-02 16:21:22 UTC
Looks good to me. Marco?
Comment 10 Marco Pesenti Gritti 2005-08-16 09:54:45 UTC
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.
Comment 11 Carlos Garcia Campos 2005-08-16 14:17:59 UTC
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
Comment 12 Marco Pesenti Gritti 2005-08-17 15:12:25 UTC
Carlos, did you announce the string change while committing?
Comment 13 Elijah Newren 2005-08-17 16:56:45 UTC
Actually, string freeze occurred before it was committed, meaning that it needs
approval from i18n or needs to be backed out...
Comment 14 Carlos Garcia Campos 2005-08-17 19:03:45 UTC
I've just fixed it. It doesn't break the freeze right now.
Comment 15 Elijah Newren 2005-08-17 20:07:48 UTC
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.
Comment 16 Carlos Garcia Campos 2005-08-17 21:02:01 UTC
I've just announced it. Thank you very much Elijah