Bug 3349 - Unable to insert a file into a message during compose.
Summary: Unable to insert a file into a message during compose.
Status: RESOLVED WORKSFORME
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: UI/Compose Window (show other bugs)
Version: 3.11.1
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2014-12-09 19:28 UTC by Marvin
Modified: 2014-12-15 13:16 UTC (History)
0 users

See Also:


Attachments
Problem file with unicode char that causes claws to raise an assert (4 bytes, application/octet-stream)
2014-12-10 02:46 UTC, Marvin
no flags Details
Improve user feedback in this case (1.24 KB, patch)
2014-12-15 13:16 UTC, Ricardo Mones
no flags Details | Diff

Description Marvin 2014-12-09 19:28:44 UTC
Steps to reproduce:

1.  Ctrl-I
2.  Select a text file from disk

Result:
No text is inserted



On stdout:

Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)' failed
Comment 1 Paul 2014-12-09 19:34:35 UTC
Works for me. Please attach a file to this bug report that exhibits this behaviour.
Comment 2 Marvin 2014-12-09 19:49:03 UTC
The file is a text file.

file file.txt tells me:

Non-ISO extended-ASCII text


Size in bytes: 252907
Comment 3 Paul 2014-12-09 20:37:26 UTC
(In reply to comment #2)
> The file is a text file.
> 
> file file.txt tells me:
> 
> Non-ISO extended-ASCII text
> 
> 
> Size in bytes: 252907

Can you attach it?
Comment 4 Marvin 2014-12-09 21:21:07 UTC
Nah, but look, I see these in the file:

http://unicode-table.com/en/search/?q=224

and

http://unicode-table.com/en/search/?q=233

and

http://unicode-table.com/en/search/?q=228

And more like that.
Comment 5 Andrej Kacian 2014-12-09 22:07:01 UTC
What about inserting file downloaded from http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt ? Does that work?
Comment 6 Marvin 2014-12-09 23:23:24 UTC
I can include that UTF8-demo file with no problems.


file UTF-8-demo.txt
UTF-8-demo.txt: UTF-8 Unicode text


file -i UTF-8-demo.txt
UTF-8-demo.txt: text/plain; charset=utf-8


and for the problem file


file -i file.txt
text/plain; charset=unknown-8bit
Comment 7 Andrej Kacian 2014-12-10 00:31:26 UTC
Well, if you do not want to attach a file you are having a problem with, then I don't think we can help you. I was not able to reproduce this no matter what I tried.
Feel free to reopen this bug once you decide to provide a file to reproduce the issue with.
Comment 8 Marvin 2014-12-10 02:46:18 UTC
Created attachment 1458 [details]
Problem file with unicode char that causes claws to raise an assert
Comment 9 Marvin 2014-12-10 02:48:23 UTC
This is the char that causes claws to raise an assert.

http://unicode-table.com/en/search/?q=146
Comment 10 Ricardo Mones 2014-12-10 09:57:16 UTC
(In reply to comment #9)
> This is the char that causes claws to raise an assert.
> 
> http://unicode-table.com/en/search/?q=146

╭────────────────────────────────────────────────────────────────
│$ wget -q -O tst 'http://www.thewildbeast.co.uk/claws-mail/bugzilla/attachment.cgi?id=1458'
│$ iconv -f UTF-8 tst
│
│
│iconv: illegal input sequence at position 2
╰────────────────────────────────────────────────────────────────

Sorry, but that file doesn't seem a valid UTF-8 encoded one.
Comment 11 Marvin 2014-12-12 19:48:29 UTC
Thinking as you all do again, it ain't easy, seems to be a documentation problem.


"When inserting a file into a current message via Ctrl-I or via the menu during compose Message->Insert file, claws uses the file extension to correctly or incorrectly determine the file type and decide what kind of file we're inserting. If claws is unable to determine the file type it will fail, going silent, but will raise an assert to stdout, so go look for stdout output your self. You may also scratch your head if that's what you want to do."
Comment 12 Marvin 2014-12-13 17:17:16 UTC
There seems to be some code already around checking what gets inserted. When trying a larger file a warning window pops-up to say something like "Are you sure you want to include a file that's this large?"* Doesn't seem like a huge leap to add a check for a file-type mismatch. For example including a text file that is not, based upon what claws considers to be text, which is unclear and seems to be a narrow definition. Maybe the definition of what claws considers to be text could also be displayed so the user knows more about what happened and might have a chance to fix the text file that claws doesn't like. Or offer a suggestion of attaching the file instead.


* I don't recall what size it showed in the size-warning pop-up, there's much inconsistency throughout claws on reporting on the size of things.
Comment 13 Ricardo Mones 2014-12-15 13:16:54 UTC
Created attachment 1460 [details]
Improve user feedback in this case

The proposed patch ensures the returned UTF-8 is valid one and warns the user if it's not possible to insert the file because of failed code conversion.
Comment 14 users 2014-12-17 17:10:02 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2014-12-17 17:10:02.557606222 +0100
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=da6173fe104763f38293b3346d9b07d44ea1e6b2
Merge: 87be2c0 ff2f663
Author: Colin Leroy <colin@colino.net>
Date:   Wed Dec 17 17:10:02 2014 +0100

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=ff2f663ebca80be4991c71be724d5a29ef5a3bdf
Author: Ricardo Mones <ricardo@mones.org>
Date:   Wed Dec 17 16:45:12 2014 +0100

    Improve feedback to user when bug #3349
Comment 15 users 2014-12-19 16:26:02 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2014-12-19 16:26:02.609610050 +0100
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=cb2051d55440b75e9cbecb408a1a16e9bc82634b
Merge: 839e527 2fc36b1
Author: Colin Leroy <colin@colino.net>
Date:   Fri Dec 19 16:26:02 2014 +0100

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=2fc36b1cd471c4b3e11e5099a85a42415395de01
Author: Colin Leroy <colin@colino.net>
Date:   Fri Dec 19 16:23:00 2014 +0100

    Better fix for bug #3349 (almost all the needed code was there :-)

Note You need to log in before you can comment on or make changes to this bug.