Closed
Bug 68993
Opened 24 years ago
Closed 24 years ago
Can't send attachment with filename containing Shift-JIS trail byte 7C
Categories
(MailNews Core :: Internationalization, defect)
Tracking
(Not tracked)
VERIFIED
FIXED
mozilla0.9.3
People
(Reporter: wesleyg, Assigned: nhottanscp)
Details
(Keywords: intl, Whiteboard: nsbranch+,pdt+, verified on the branch)
Attachments
(5 files)
4 bytes,
text/plain
|
Details | |
600 bytes,
patch
|
Details | Diff | Splinter Review | |
612 bytes,
patch
|
Details | Diff | Splinter Review | |
1.90 KB,
patch
|
Details | Diff | Splinter Review | |
725 bytes,
patch
|
Details | Diff | Splinter Review |
<summary>
Can't send attachment with filename containing Unicode 7AF9 code point
<repro environment>
build 02-15-06 + Win98-JA
not repro on:
IE5.5 + Win98-JA
<repro steps>
1. save a file containing the Unicode code point value 7AF9 (The Japanese
character "take", takenoko no take)
2. try to send the file as an attachment (optional step: set the character
coding to Japanese ISO-2022-JP before sending message)
<result>
Alert message "Sending of the message failed".
Reporter | ||
Comment 1•24 years ago
|
||
Reporter | ||
Comment 2•24 years ago
|
||
not repro on:
build 02-14-08 + Mac OS 9.04-JA
Assignee | ||
Comment 3•24 years ago
|
||
Is that specific to \u7AF9 only?
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9
Another character which has the same trail byte: ‘| (souji no sou) has this problem as well.
Reporter | ||
Comment 6•24 years ago
|
||
Changed Summary to "Can't send attachment with filename containing Shift-JIS
trail byte 7C"
Summary: Can't send attachment with filename containing Unicode 7AF9 code point → Can't send attachment with filename containing Shift-JIS trail byte 7C
Assignee | ||
Comment 7•24 years ago
|
||
How about the "Attachments:" area in the compose window?
Is the file name shown correctly in there?
Yes, the Japanese attachment filename showing correctly on the compose window.
Checked Mac build. On Mac, the mail with the attachment can be sent out,
but when received, the attachment filename containing this kind of problematic
chars is not displayed correctly on the envelope, for example, filename of
"take" is displayed as "%92|"
Assignee | ||
Comment 10•24 years ago
|
||
On Macintosh, the file name is not MIME encoded at all. That's not specific to
"TAKE" character. I used MacOS9 JA. We need to see if this is Mac specific.
Xianglan, could you send two messages to nhotta from Windows JA? One with file
name "TAKE" and other with a file name without 0x7C?
Comment 11•24 years ago
|
||
Naoki, I just sent you a mail with an attachment w/o "0x7c" in the filename.
Sending a mail with an attachment filename containing "0x7c" always fails on
Windows.
Comment 12•24 years ago
|
||
>On Macintosh, the file name is not MIME encoded at all. That's not >specific to
"TAKE" character. I used MacOS9 JA. We need to see if this >is Mac specific.
Yes. On Mac, whether the filename is MIME encoded or not depends on the filename
length. If the Ja filename contains 4 or less Japanese chars, the filename won't
get MIME encoded. If the filenames contains more chars, it gets MIME encoded,
but not correctly encoded if it is sent from an English Mac OS. So the only
working condition is to send the mail from a Japanese MAC OS and the filename
must contains 5 or more Ja chars. I'll file a seperate bug for this.
Comment 13•24 years ago
|
||
And the problem I mentioned above is Mac specific.
Comment 14•24 years ago
|
||
On Ja Mac, the "0x7c" char doesn't cause the problem as it does on Windows. I
used the filename containing more than 5 ja chars and one of chars is "0x7c"
char, sending doesn't fail and filename shows correctly on the envelope. So it
looks like the "0x7c" problem is win32 specific.
Comment 15•24 years ago
|
||
Bug 70341 has been filed for the Mac specific problem.
Assignee | ||
Comment 16•24 years ago
|
||
nsMsgComposeAndSend::AddCompFieldLocalAttachments in nsMsgSend.cpp, it replaces
'|' by ':'.
http://lxr.mozilla.org/seamonkey/source/mailnews/compose/src/nsMsgSend.cpp#1854
1854 #ifdef XP_WIN
1855 str.ReplaceChar('|', ':');
1856 #endif
Cc to ducarroz, do you know why this is needed?
Comment 17•24 years ago
|
||
The "|" character appears when you convert a Windows filespec into a URL,
e.g.:
C:\netscape\myfile.html
becomes
C|/netscape/myfile.html
I don't pressume to know this code, but why are we manipulating char* here
and not Unicode strings? We have similar native-file to URL conversions in
Composer in File Save methods where the use of Unicode prevents this kind of
problem.
Assignee | ||
Comment 18•24 years ago
|
||
I agree using unicode is better, that would be a separate project.
Since the code is in #ifdef WIN, I am going to use ::IsDBCSLeadByte to avoid
replacing DBCS characters.
Comment 19•24 years ago
|
||
we should no hack the path manually if we want to make a url with it, we have
API for that!
Assignee | ||
Comment 20•24 years ago
|
||
So can we replace the line
1855 str.ReplaceChar('|', ':');
with that API? Where is that API?
Also we can change to replace a substring "|\" instead of a character '|'.
Comment 21•24 years ago
|
||
you should be able to do something like that:
nsCOMPtr<nsILocalFile> localFile = do_CreateInstance(NS_LOCAL_FILE_CONTACTID, &rv);
localFile->InitWithPath(filePath) or InitWithUnicodePath
char* url;
localFile->GetURL(url);
Assignee | ||
Comment 22•24 years ago
|
||
nsMsgAttachmentHandler is written using nsFileSpec and the string "str" is used
for other things. Also I am not sure if nsMsgNewURL() is exactly equivalent to
nsILocalFile::GetURI().
For this bug, I am going with replacing "|\".
1875 nsMsgNewURL(&(m_attachments[newLoc].mURL), str);
1876
1877 if (m_attachments[newLoc].mFileSpec)
1878 delete (m_attachments[newLoc].mFileSpec);
1879 m_attachments[newLoc].mFileSpec = new nsFileSpec( nsFileURL((const
char *) str) );
1880
1881 if (m_attachments[newLoc].mURL)
1882 msg_pick_real_name(&m_attachments[newLoc],
mCompFields->GetCharacterSet());
1883
1884 // Now, most importantly, we need to figure out what the content
type is for
1885 // this attachment...If we can't, then just make it
application/octet-stream
1886 nsresult rv = NS_OK;
1887 nsCOMPtr<nsIMIMEService> mimeFinder
(do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
1888 if (NS_SUCCEEDED(rv) && mimeFinder)
1889 {
1890 char *fileExt =
nsMsgGetExtensionFromFileURL(NS_ConvertASCIItoUCS2(str));
1891 if (fileExt)
1892 mimeFinder->GetTypeFromExtension(fileExt,
&(m_attachments[newLoc].m_type));
1893
1894 PR_FREEIF(fileExt);
1895 }
Assignee | ||
Comment 23•24 years ago
|
||
Assignee | ||
Comment 24•24 years ago
|
||
As long as I seen in the debugger, the string is already ":/" instead of "|/".
The change was made in 09/1999 it may be not be needed anymore.
I also do not understand why it's changing from URL to native windows style.
Anyway, I don't intend to rewrite the attachment code for this bug.
Jean-Francois, please review.
Comment 25•24 years ago
|
||
R=ducarroz
Comment 26•24 years ago
|
||
replacing | with : broke shift-jis
will replacing |/ with :/ break any encoding?
is there a way to fix this without using such a hack? if that is beyond the
scope of this bug, we should at least open a new bug on that (and probably
assign it to ducarroz).
Comment 27•24 years ago
|
||
why not just totally remove this hack! If you are still able to send file on
window, I will vote for it...
Assignee | ||
Comment 28•24 years ago
|
||
Assignee | ||
Comment 29•24 years ago
|
||
Jean-Francois, please review the new patch, send attachment and send webpage
still works without that line.
Comment 30•24 years ago
|
||
great, R=ducarroz
Assignee | ||
Comment 31•24 years ago
|
||
Filed a bug 71535 for nsFileSpec issue.
Comment 32•24 years ago
|
||
sr=sspitzer
Assignee | ||
Comment 33•24 years ago
|
||
checked in
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 35•24 years ago
|
||
It's impossible to send out this kind of attachments with no or other file
extensions, like .doc. Reopened the bug.
Status: VERIFIED → REOPENED
Resolution: FIXED → ---
Comment 36•24 years ago
|
||
give nhotta to investiate this issue.
Target Milestone: mozilla0.9 → mozilla0.9.3
Assignee | ||
Comment 37•24 years ago
|
||
There is an error when try to create a temp file.
For .html and .txt, name of the temp file is something like "nsmail.tmp". But
other files, the original file name is used. The error happens in NSPR called by
nsILocalFile. I think NSPR does not recognize multi-byte file names.
It might be possible to try another name after the failure.
Assignee | ||
Comment 38•24 years ago
|
||
Assignee | ||
Comment 39•24 years ago
|
||
Assignee | ||
Comment 40•24 years ago
|
||
I asked varada to review the patch.
IQA, is 0x7c the only case it fails? Please try other characters (e.g.
characters from 0x8940 to 0x897E). I think easy way is to create four files each
has 15 characters (e.g. 0x8940 - 0x894F), so you don't need to try 60 different
cases.
Comment 41•24 years ago
|
||
Windows will fail with <>/\:*?"| and not just |
Assignee | ||
Comment 42•24 years ago
|
||
They are under 0x40 (except 0x5c and 0x7c) not overwrap with Shift_JIS charset
which is used for JA windows file system.
I tried a case 0x5c but did not have the problem.
Assignee | ||
Comment 43•24 years ago
|
||
cc to varada@netscape.com, please see my last comment
Comment 44•24 years ago
|
||
I tried the filename containing characters in 0x8940 to 0x897E, only 897c
character causes this problem.
Comment 45•24 years ago
|
||
The patch is good; r=varada
Comment 46•24 years ago
|
||
R=ducarroz
Comment 47•24 years ago
|
||
sr=bienvenu
Assignee | ||
Comment 48•24 years ago
|
||
Checked in to the trunk.
Comment 49•24 years ago
|
||
I have a problem with this fix.
here's the code as it stands now:
tempName = GenerateFileNameFromURI(mURL); // Make it a sane name
#ifdef XP_WIN
if (tempName && PL_strchr(tempName, '|'))
{
PR_Free(tempName);
tempName = nsnull;
}
#endif
#ifdef XP_MAC
if (tempName && PL_strlen(tempName) >= 31)
PR_DELETE(tempName)
#endif
basically, you are hacking it so if GenerateFileNameFromURI() doesn't generate
a sane name, you throw it away and use "nsmail-X.tmp".
my issue with the code is it isn't XP (what about OS/2?) about about other
characters?
instead of tacking on changes using #ifdef XP_foo, you should fix
GenerateFileNameFromURI() to really generate a "sane name"
I'd fix GenerateFileNameFromURI() to use NS_MsgHashIfNecessary(), which is how
we've been turning a given string into something safe for the underlying OS.
it will take care of long file names and file names with illegal chars.
Assignee | ||
Comment 50•24 years ago
|
||
For this bug, I intended to do a small change for this specific problem and
tried not to affect others (because of nsBranch). So I did the same thing that
is already working for Macintosh.
If there is no actual problem of creating "nsmail-X.tmp" then I would like to
land this to the branch.
I did not know about NS_MsgHashIfNecessary(). Your suggested change seems to be
the right one. By doing that, we could remove those ifdef code. Can that be done
by a separate bug?
Comment 51•24 years ago
|
||
I've logged #89090 on the code cleanup.
Comment 52•24 years ago
|
||
seth- do you agree it is low risk and right thing to do to land the current
patch into moz0.9.2 branch as vtrunk+ rule ?
Comment 53•24 years ago
|
||
ftang, yes I think the fix is low risk.
I'm not 100% convinced it is correct. nhotta should double check that there
aren't other illegal characters (or illegal lengths) that will cause the same
problem.
Assignee | ||
Comment 54•24 years ago
|
||
Xianglan tested cases which covers possible overwrap between Shift_JIS and ASCII.
I think other CJK file system charsets are hi bit on so do not have this problem.
> ------- Additional Comments From ji@netscape.com 2001-06-29 17:44 -------
>
> I tried the filename containing characters in 0x8940 to 0x897E, only 897c
> character causes this problem.
>
Comment 57•24 years ago
|
||
fix and land ito m92
Comment 58•24 years ago
|
||
nhotta-
should we land this into trunk untill 89090 happen ?
Comment 59•24 years ago
|
||
sorry, I am confused, this have already been check into trunk. Mark it fixed.
Status: REOPENED → RESOLVED
Closed: 24 years ago → 24 years ago
Resolution: --- → FIXED
Comment 60•24 years ago
|
||
Verified with 07/11 branch build.
Whiteboard: nsbranch+,pdt+ → nsbranch+,pdt+, verified on the branch
Updated•21 years ago
|
Product: MailNews → Core
Updated•17 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•