If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Attached .rtf files are opened as though they were flat text (TXT) files and show all the control characters

RESOLVED FIXED

Status

Thunderbird
General
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: John_Ha, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Build Identifier: v3.1.2  Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2

When I double click on a .rtf (Rich Text Format) file attached to an email I have received, the default application (I have associated OpenOffice Writer which can read .rtf files) opens the file as a flat text (ie a TXT) file and displays all the control characters.  It does not respect the .rtf qualifier.

If the file is called fred.rtf, the OO Writer bar shows "fred.rtf-4.txt (Read only) - OpenOffice.org Writer".  The 4 increments by 1 every time I retry.  This means that Thunderbird appears to have appended a TXT qualifier after the RTF qualifier.  OO Writer is therefore being told that this is a TXT file, not an RTF file.  No doubt this is why I see all the control characters.

If I detach fred.rft and save it to my hard disk, OpenOffice opens the file properly and I see the correct contents.  This is as expected - OpenOffice can read and write .rtf files.  The file is obviously OK.

I am running Windows 7 so I looked in the temporary folder C:\Users\my_name\AppData\Local\Temp where Thunderbird creates the temporary, read only file it views. When I double clicked on the .rtf file attached to the email, a file called fred.rtf.txt appeared in the Temp folder, and OpenOffice opened this file. 

If I forward the received email with the attached fred.rtf file, then while I am editing the email I am forwarding, I can open the attached fred.rtf file with Writer, and it opens OK.  When I check in the Temp folder, the file Thunderbird has created is called nsmail-8.tmp - ie it is NOT a TXT, nor an RTF file. OO obviously pens this TMP file OK.

The email header is:
Content-Type: application/octet-stream;
name="fred.rtf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="fred.rtf"

As a test, I renamed the file in \Temp from fred.rtf.txt to fred.rtf - that is I just removed the extra .txt extension added by Thunderbird.  When I double clicked on the renamed file in the Temp folder, it opened OK in OO. 

Some recipients of my emails with attached RTF files have commented that they cannot open the RTF files. 

There appear to be a number of similar bugs reported - namely https://bugzilla.mozilla.org/show_bug.cgi?id=213393, https://bugzilla.mozilla.org/show_bug.cgi?id=205871 and https://bugzilla.mozilla.org/show_bug.cgi?id=580585

Reproducible: Always

Steps to Reproduce:
1.  Create an RTF file called fred.rtf which contains the single text word zebra.

2.  Edit and email and attach the file fred.rtf to the email.

3.  While I am editing the email, if I click on fred.rtf, it opens OK and I see the word zebra.

4  Send myself the email.  

5  Receive the email and click on the fred.rtf attachment in order to open it.  It opens with my default application OpenOffice Writer, but all the control characters are shown, namely
{\rtf1\ansi\deff0\adeflang1025
{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Times New Roman;}{\f4\froman\fprq0\fcharset0 Times New Roman;}{\f5\fnil\fprq0\fcharset0 times new roman{\*\falt new york};}{\f6\fmodern\fprq1\fcharset128 MS Mincho{\*\falt \'82\'6c\'82\'72 \'96\'be\'92\'a9};}{\f7\fnil\fprq0\fcharset0 Mangal;}} ... etc

3  Detach fred.rtf from the email and store it on my hard disk.  Open it with OO - it opens OK and I see the word zebra.


Expected Results:  
When I open an RTF file I expect to see only the formatted text - I do not expect to see all the control characters.

A workaround is to detach the rtf file from the email before opening.

Why does the temporary file in C:\ ...\Temp have TXT added as its qualifier after RTF??

Windows 7 Home 64 bit, 4GB, dual core CPU
> The email header is:
> Content-Type: application/octet-stream; name="fred.rtf"

The .rtf file is not sent with proper or general Content-Type: application/msword.

Is the attached .rtf file consists of ordinal text only? (no control chars, no mixed new-line chars, e.g. CRLF only instead of mixture of CRLF/LF/CR, ...)
If so, similar phenomenon to bug 576663 can happen, because "relation between file extension and content type registered to Windows Registry" is not checked by quirks for application/octet-stream. If sniffed as "text", ".TXT" is currently added to temporary file.

Do workaround procedure written in bug 576663 please, if many .rtf files are sent to you with Content-Type: application/octet-stream instead of proper Content-Type: application/msword.
(Reporter)

Comment 2

7 years ago
Created attachment 473535 [details]
fred.rtf is an RTF file created in OpenOffice.  It contains the single word   zebra

I created this file fred.rtf by
1  Start OpenOffice Writer
2  Create new text document
3  Type the single word   zebra   in the document
4  Save As > and choose RTF = Rich Text Format
5  Save as fred.rtf
(Reporter)

Comment 3

7 years ago
Thank you for your response Wada.  I will do my best to answer all your points.

> Is the attached .rtf file consists of ordinal text only?  (no control chars,
> no mixed new-line chars, e.g. CRLF only instead of mixture of CRLF/LF/CR, ...)

Sorry, I cannot be sure I will answer correctly so I have instead attached fred.rtf so you can see the entire file - it is 2kB.

> Do workaround procedure written in bug 576663 please

I went to bug 576663 and followed the procedure in comment 23, namely I

1  Save the email with the rtf file attached as an eml file on my desktop
2  Open the eml file with Notepad editor
3  Find the lines
_____Content-Type: application/octet-stream;
_____name="fred.rtf"
4  Change the first line to 
_____Content-Type: application/msword;
_____name="fred.rtf"
5  Save the edited eml file
6  Start TB, File > Open Saved Message > navigate to eml file > select eml file.  The email opens correctly
7  Double click on fred.rtf.  I get a small window open which asks "you have chosen to open fred.rtf which is an OpenOffice ... etc, and I clicked OK. 
9  The file opened correctly and I can see the word  zebra.  
10 The OpenOffice Window name bar has fred-1.rtf (read-only) - OpenOffice.org Writer - ie is does NOT have fred-1.rtf.TXT as before

Other points:
1  I have set Windows file associations such that OpenOffice Writer is my default program to open RTF files. 
2  At Stage 8, I would expect the RTF file to open without further intervention on my part.  Instead, I have to give my approval to the extra window which appears.  
3  If I forward the email, and double click on the RTF file while I am editing the email, the RTF file opens directly without asking for my approval as in Step 7 above.  SO it appears to use a different method to open the file??
4  I used Thunderbird to create the email with fred.rft attached.  So TB created the header "Content-Type: application/octet-stream" quoted in 3 above.  If this header is wrong, then this is perhaps a separate TB bug which needs reporting.
5  I checked in C:\Users\my_name\AppData\Local\Temp and the temporary file was called fred-1.rft - it did not have the TXT added after the RFT.

I trust this answers your questions.  If you would like me to attach the eml file I will do so (after obscuring my email ID).
(Reporter)

Comment 4

7 years ago
I have been doing some testing with a colleague who is running TB 3.0.6 under XP, and we are getting different results.

1  His TB 3.0.6 can open RTF files OK which are attached to emails I send from my TB 3.1.0.  So even though my TB 3.1.0 sends a header "application/octet-stream", his 3.0.6 opens the rtf file OK.

2  My TB 3.1.0 can open RTF files OK which are attached to emails he sends me from TB 3.0.6.  I think this may be because his TB 3.0.6 inserts a different header for RTF files.  TB 3.0.6 adds application/rtf as here: 

__Content-Type: application/rtf;
__ name="Test.rtf"
__Content-Transfer-Encoding: base64
__Content-Disposition: attachment;
__ filename="Test.rtf"

whereas my TB 3.1.0 adds application/octet-stream as here:

__Content-Type: application/octet-stream;
__ name="fred.rtf"
__Content-Transfer-Encoding: base64
__Content-Disposition: attachment;
__ filename="fred.rtf"

I never experienced problems before so I am now wondering if this problem was introduced by a release later than TB 3.0.6. 

I would have expected TB to use "Content-Type: application/rtf" as RTF is an international standard.  I cannot see why TB would want to use the "Content-Type: application/msword" suggested in Comment 1.  RTF has nothing to do with MS Word.
(Reporter)

Comment 5

7 years ago
The problem has fixed itself.  I do not know what I did to fix it, but it is now OK.  I do apologise for causing you work :-(((  

At 3pm this afternoon, emails I was sending which had RTF files attached were being sent with 
__Content-Type: application/octet-stream;
__ name="fred.rtf"

and when I received them, I could not open the attached RTF file.

At 7pm, emails I am sending with RTF files attached are being sent with 

__Content-Type: application/rtf;
__ name="fred.rtf"

and I can open the attached RTF file when I receive them.

The only thing which I think that I have changed is Tools > Options > Attachments.  I originally had lots of associations, but as part of my debugging, I deleted all the associations and re-associated them.  

I cannot recall what I had previously, but I now have TXT files associated with Notepad; and RTF files associated with OpenOffice Writer (my default RTF application) and everything works OK.
(In reply to comment #4)
> I cannot see why TB would want to use the "Content-Type: application/msword" suggested in Comment 1.

In my environment, HKEY_CLASSES_ROOT\.rtf was set by MS Word Viewer. It's probably reason why Content Type=application/msword was set in my Windows registry. Open Office looks to set general Content Type=application/rtf. Please read "/msword" in my comment "/rtf". 

(In reply to comment #5)

Your problem was probably caused by;
 a) mimeTypes.rdf entry for .rtf -> application/octet-stream
    => .rdf file was attached with application/octet-stream by Tb
 b) mimeTypes.rdf entry for application/octet-stream -> .txt
    => .txt attachment was not opened by Notepad by default
And, as attached .rtf content is pure text(7bit ascii ordinal chars + CRLF only), I guess bug 576663 occurs with cleared mimeTypes.rdf.

Will ".TXT" be appended to file name when you open ".rtf attachment of application/octet-stream" after deletion of mimeTypes.rdf and restart of Tb?
If added ".TXT" for .rtf of application/octet-stream is observed with cleared mimeTypes.rdf, correct workaround of bug 576663 was involved in your next action.
> I deleted all the associations and re-associated them.  
Clearing of mimeTypes.rdf and opening of ".rtf attachment of correct Content-Type: application/rtf" with "open with the App always" is one of best workaround procedures. Once association of .rtf<->application/rdf is defined in mimeTypes.rdf, bug 576663 won't occur on .rtf atachment of application/octet-stream.
(Reporter)

Comment 8

7 years ago
Thank you Wada.

> Will ".TXT" be appended to file name when you open ".rtf attachment of 
> application/octet-stream" after deletion of mimeTypes.rdf and restart of Tb?

I apologise, but I am not sure that I understand your question.  What I think you are asking is that I edit the .eml file I created in Comment 3 so that it reads:

__Content-Type: application/octet-stream;
__ name="fred.rtf"

and then open the email, and then open the RTF file while it is still attached to the email. 

I did so, and the RTF file opens OK, and the OO window shows fred-1.rtf (read-only).  In other words, .TXT is not being added to the temporary file name.

I have changed the STATUS to RESOLVED FIXED.

Many thanks for your help.  If you would like me to do more testing I will be happy to do it.

I now remember that I also added lots of associations in Windows 7 by Start > Control Panel > Default programs.  I set OO so it now has everything it can open associated with it.  This may not have had any effect because OO always had RTF associated with it, and RTF was never associated with any other program.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.