Bug#242927: Gtranslator crashes when saving file with Hebrew chars

2005-01-28 Thread Loïc Minier
forwarded 242927 http://bugzilla.gnome.org/show_bug.cgi?id=139738
thanks

Hi,

Lior Kaplan [EMAIL PROTECTED] - Fri, Jan 28, 2005:

 I was able to reproduce the crash by taking a Hebrew PO file from D-I, 
 saving it as windows-1255 encoding and manually remove the encoding like 
 inside the file (which says UTF-8).

 Ok, I reproduced the problem by removing the charset=UTF-8 part of a
 Content-Type from a random po file and reported this upstream.

   Regards,

-- 
Loïc Minier [EMAIL PROTECTED]
Neutral President: I have no strong feelings one way or the other.




Bug#242927: Gtranslator crashes when saving file with Hebrew chars

2005-01-28 Thread Loïc Minier
tags 242927 + patch pending
thanks

Hi,

 Your problem has been fixed and an upload should come soon.  Attached
 is a patch fixing the problem.

   Regards,

-- 
Loïc Minier [EMAIL PROTECTED]
Neutral President: I have no strong feelings one way or the other.
#! /bin/sh /usr/share/dpatch/dpatch-run
## 99-unnamed.dpatch by Loic Minier [EMAIL PROTECTED]
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
--- gtranslator-1.1.5.orig/src/header_stuff.c
+++ gtranslator-1.1.5/src/header_stuff.c
@@ -146,15 +146,43 @@
if_key_is(Content-Type) {
gchar *prefix;

-   prefix = strstr (pair[1], text/plain; charset=);
-   if (prefix)
-   ph-charset = g_strdup (prefix + 20);
+   /* check whether we've got text/plain */
+   prefix = strstr (pair[1], text/plain);
+   if ((! prefix) || prefix != pair[1])
+   {
+   g_warning(Content-Type doesn't start with 
text/plain (got '%s'), pair[1]);
+   }
+   /* search for a charset= parameter */
+   /* (note that we're cool since we allow other params
+* to be passed too!) */
+   prefix = strstr (pair[1], ; charset=);
+   if (prefix) {
+   /* we should check for allowed charsets --
+* a complete list can be found in section 5.2,
+* Filling in the Header Entry, in the gettext
+* manual -- and default to detecting the
+* encoding */
+   ph-charset = g_strdup (prefix + 10);
+   }
else
-   ph-charset = g_strdup (pair[1]);
+   {
+   /* no charset= parameter
+* gtranslator used to default to pair[1].
+* The best thing to do would be to detect
+* the encoding, but frankly people should
+* simply put a charset */
+   g_warning(Content-Type has no charset 
parameter (got '%s'), defaulting to UTF-8, pair[1]);
+   /* we g_strdup() it so it can be freed
+* transparently */
+   ph-charset = g_strdup (UTF-8);
+   }
}
else
if_key_is(Content-Transfer-Encoding)
-   ph-encoding = g_strdup(pair[1]);
+   {
+   /* we should warn for anything else than 8-bit */
+   ph-encoding = g_strdup(pair[1]);
+   }
else
if_key_is(Plural-Forms)


Bug#242927: Gtranslator crashes when saving file with Hebrew chars

2005-01-27 Thread Lior Kaplan
Hi Loïc,
Thanks for the showing interest in this bug report.
I was able to reproduce the crash by taking a Hebrew PO file from D-I, 
saving it as windows-1255 encoding and manually remove the encoding like 
inside the file (which says UTF-8).

When saving the file with a Hebrew chars, the application crashed. See 
the attach debug info from bug buddy.

Let me know if you need more info.
I'm CCing the bug report to keep recored of this.
Loïc Minier wrote:
Hi,
 This is a followup for Debian bug http://bugs.debian.org/242927.
Lior Kaplan [EMAIL PROTECTED] - Fri, Apr 09, 2004:

When trying to save a PO file which has Hebrew chars the program crashes.
It also empties the file contents.
...
6. A crash happen...
7. File is truncated to 0 bytes. (=data loss).

Lior Kaplan [EMAIL PROTECTED] - Sat, Jul 03, 2004:
I found out that this kind of crash happens when the po file encoding
isn't UTF-8. When the encoding is UTF-8 I can save Hebrew without
problems.

 It's nice that you found a _workaround_, but if a crash was happening,
 it's best to fix it!
 I could not reproduce your problem, do you still get the crash?
 If you get the crash, can you please install bug-buddy and get a stack
 trace?
   Thanks,
--
Regards,
Lior Kaplan
[EMAIL PROTECTED]
http://www.Guides.co.il
Debian GNU/Linux unstable (SID)
Backtrace was generated from '/usr/bin/gtranslator'

(no debugging symbols found)
Using host libthread_db library /lib/tls/libthread_db.so.1.
(no debugging symbols found)
`system-supplied DSO at 0xe000' has disappeared; keeping its symbols.
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 1088746176 (LWP 4117)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
0x408ae4ee in __waitpid_nocancel () from /lib/tls/libpthread.so.0
#0  0x408ae4ee in __waitpid_nocancel () from /lib/tls/libpthread.so.0
#1  0x40080434 in libgnomeui_module_info_get ()
   from /usr/lib/libgnomeui-2.so.0
#2  signal handler called
#3  0x080662ea in gtranslator_parse_the_file_from_file_dialog ()
#4  0x4074a28f in g_list_foreach () from /usr/lib/libglib-2.0.so.0
#5  0x08066607 in gtranslator_save_file ()
#6  0x407021f6 in g_cclosure_marshal_VOID__VOID ()
   from /usr/lib/libgobject-2.0.so.0
#7  0x406f0686 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#8  0x40701d1f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0
#9  0x40700dec in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#10 0x40701076 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#11 0x402312a5 in gtk_button_clicked () from /usr/lib/libgtk-x11-2.0.so.0
#12 0x402322bb in _gtk_button_paint () from /usr/lib/libgtk-x11-2.0.so.0
#13 0x407021f6 in g_cclosure_marshal_VOID__VOID ()
   from /usr/lib/libgobject-2.0.so.0
#14 0x406f0919 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0
#15 0x406f0686 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#16 0x407015a1 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0
#17 0x40700dec in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#18 0x40701076 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#19 0x402311f5 in gtk_button_released () from