Closed
Bug 415761
Opened 17 years ago
Closed 15 years ago
nsIconChannel::GetHIconFromFile does not support Unicode filenames on Windows
Categories
(Core :: Graphics: ImageLib, defect, P4)
Tracking
()
RESOLVED
FIXED
mozilla1.9.2a1
People
(Reporter: martijn.martijn, Assigned: khuey)
References
()
Details
Attachments
(4 files, 3 obsolete files)
3.09 KB,
patch
|
khuey
:
review+
vlad
:
superreview+
|
Details | Diff | Splinter Review |
3.00 KB,
patch
|
beltzner
:
approval1.9.1.1-
|
Details | Diff | Splinter Review |
2.23 KB,
patch
|
neil
:
review-
|
Details | Diff | Splinter Review |
2.50 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
To reproduce: - go to http://www.baidu.com/ - Got to File->Save Page As... and save the page. Expected result: The file is saved (named 百度一下,你就知道.htm currently), the html icon is used should be showing at the left for the download item in the download manager. Actual result: No icon at all is shown for the download item at the left in the download manager. Maybe there is some relation to bug 355461 here? It seems to happen on this site, but my suspicion is that this happens as soon as saved filename contains at least one utf-8 character. That's why I'm asking blocking-firefox3?, although the issue itself is rather smallish.
Flags: blocking-firefox3?
Updated•17 years ago
|
Flags: blocking-firefox3? → blocking-firefox3+
Priority: -- → P3
Comment 1•17 years ago
|
||
Is this a regression from 2.0? This probably has something to do with the moz-icon code...
Updated•17 years ago
|
Whiteboard: [needs assignee]
Updated•17 years ago
|
Priority: P3 → P4
Comment 2•17 years ago
|
||
Simon - might this also be related to bug 393488, or am I barking up the wrong tree?
Comment 3•17 years ago
|
||
I'm guessing it's some issue with the windows implementation of moz-icon because it works okay on os x. CCing some people that might know if it's so. http://mxr.mozilla.org/seamonkey/source/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp Shawn: I suppose we could work around this by requesting a generic moz-icon if we think the icon will choke on UTF8 files. e.g., moz-icon://.dmg?size=32 moz-icon://.txt?size=32 moz-icon://.pdf?size=32
Comment 4•17 years ago
|
||
The icon code still uses ANSI APIs. It probably needs to use the Unicode APIs.
Comment 6•17 years ago
|
||
Not blocking on this bug for final ship. Would take a safe enough patch if one comes through.
Flags: wanted-firefox3+
Flags: blocking-firefox3-
Flags: blocking-firefox3+
Updated•16 years ago
|
Product: Firefox → Toolkit
Assignee | ||
Comment 7•16 years ago
|
||
Confirmed on Vista as well. I'm going to play with this one.
Assignee | ||
Comment 8•15 years ago
|
||
Could somebody with bug edit access please do the following: -Assign the bug to me -Move it from download manager to Core:Imagelib -Change the title to "nsIconChannel::GetHIconFromFile does not support Unicode filenames on Windows" -Change the platform to Windows I believe I'll have a patch ready for this late tomorrow or by friday at the latest.
Updated•15 years ago
|
Component: Download Manager → ImageLib
Product: Toolkit → Core
QA Contact: download.manager → imagelib
Updated•15 years ago
|
Assignee: nobody → me
Summary: No icon for the saved file in the download manager when the filename contains unicode character → nsIconChannel::GetHIconFromFile does not support Unicode filenames on Windows
Comment 9•15 years ago
|
||
(In reply to comment #8) Done; thanks!
Assignee | ||
Comment 10•15 years ago
|
||
Safe, simple, should do the trick. Apparently when this code was Unicode converted somebody missed the string handling, because it uses wide syscalls but handles the strings in ASCII.
Attachment #377416 -
Flags: review?
Assignee | ||
Updated•15 years ago
|
Attachment #377416 -
Flags: review? → review?(pavlov)
Assignee | ||
Comment 11•15 years ago
|
||
Once reviewed and checked in on trunk I think we should back this into 1.9.1 as well. I'll set those flags down the road though.
Status: NEW → ASSIGNED
Whiteboard: [needs assignee]
Comment 12•15 years ago
|
||
Kyle, how did you create that patch file? Is it on a mq or committed? Could you export the patch using hg export.. something like: hg export --config "diff.unified=8" tip (assuming your patch is applied and is on the tip)
Assignee | ||
Comment 13•15 years ago
|
||
Code same as before, patch is slightly different per Edward's comment.
Attachment #377416 -
Attachment is obsolete: true
Attachment #377425 -
Flags: review?
Attachment #377416 -
Flags: review?(pavlov)
Assignee | ||
Updated•15 years ago
|
Attachment #377425 -
Flags: review? → review?(pavlov)
Comment 14•15 years ago
|
||
Comment on attachment 377425 [details] [diff] [review] Patch for nsIconChannel::GetHIconFromFile() >+ nsAutoString filePath(NS_ConvertASCIItoUTF16(fileExt).get()); You definitely don't need the .get() in this particular case. In fact, you might find that NS_ConvertASCIItoUTF16 filePath(fileExt); works.
Comment 15•15 years ago
|
||
Comment on attachment 377425 [details] [diff] [review] Patch for nsIconChannel::GetHIconFromFile() >+ // Declare as nsAutoString for wide character support (see Bug 415761) No need for this comment. Otherwise, looks good. Check Neil Rashbrook's comments too, though. (Also: I'm now the imagelib maintainer - you'll have more luck getting reviews out of me than out of Stuart. :)
Attachment #377425 -
Flags: review?(pavlov) → review+
Assignee | ||
Comment 16•15 years ago
|
||
Thanks Joe. I'll post a slightly cleaned up version before I ask for superreview.
Assignee | ||
Comment 17•15 years ago
|
||
Attachment #377425 -
Attachment is obsolete: true
Attachment #377847 -
Flags: superreview?
Attachment #377847 -
Flags: review+
Assignee | ||
Updated•15 years ago
|
Attachment #377847 -
Flags: superreview? → superreview?(tor)
Comment 18•15 years ago
|
||
(In reply to comment #14) > You definitely don't need the .get() in this particular case. In fact, you > might find that NS_ConvertASCIItoUTF16 filePath(fileExt); works. Neil, doesn't that rely on the implementation of NS_ConvertASCIItoUTF16 being an object? Is that a safe assumption?
Updated•15 years ago
|
Attachment #377847 -
Flags: superreview?(tor) → superreview?(vladimir)
Assignee | ||
Comment 19•15 years ago
|
||
Is it ever not an object? I mean I'm not terribly familiar with the mozilla code yet, but everything I've read on MDC indicates it's a class that only differs from nsAutoString in the constructor.
Comment on attachment 377847 [details] [diff] [review] Patch for nsIconChannel::GetHIconFromFile >- nsCAutoString filePath(fileExt); >- if (localFile) >+ NS_ConvertASCIItoUTF16 filePath(fileExt); >+ if (localFile) This should probably be allocated from a nsString, initialized from a NS_Convert... -- filePath may be modified in the if block, and we really shouldn't modify an object of type NS_ConvertASCIItoUTF16. >- filePath = NS_LITERAL_CSTRING(".") + defFileExt; >+ filePath = NS_ConvertASCIItoUTF16(NS_LITERAL_CSTRING(".") + defFileExt); This should probably be NS_LITERAL_STRING(".") + defFileExt >- shellResult = ::SHGetFileInfoW(NS_ConvertUTF8toUTF16(filePath).get(), >+ shellResult = ::SHGetFileInfoW(filePath.get(), I -think-, to be fully correct, you want to use nsPromiseFlatString(filePath).get() here to ensure you get a null-terminated string.
Comment 21•15 years ago
|
||
(In reply to comment #20) > >- nsCAutoString filePath(fileExt); > >- if (localFile) > >+ NS_ConvertASCIItoUTF16 filePath(fileExt); > >+ if (localFile) > This should probably be allocated from a nsString, initialized from a > NS_Convert... -- filePath may be modified in the if block, and we really > shouldn't modify an object of type NS_ConvertASCIItoUTF16. Well, I thought I'd seen that done before, but if you don't like that, then I believe the next best thing is to use CopyASCIItoUTF16(fileExt, filePath); > >- filePath = NS_LITERAL_CSTRING(".") + defFileExt; > >+ filePath = NS_ConvertASCIItoUTF16(NS_LITERAL_CSTRING(".") + defFileExt); > This should probably be NS_LITERAL_STRING(".") + defFileExt I don't think that's right; defFileExt isn't Unicode, but you could use filePath.AssignLiteral("."); AppendASCIItoUTF16(defFileExt, filePath); for instance. > >- shellResult = ::SHGetFileInfoW(NS_ConvertUTF8toUTF16(filePath).get(), > >+ shellResult = ::SHGetFileInfoW(filePath.get(), > I -think-, to be fully correct, you want to use > nsPromiseFlatString(filePath).get() here to ensure you get a null-terminated > string. ns(Auto)String is null-terminated. nsAString needs PromiseFlatString (no ns).
Assignee | ||
Comment 22•15 years ago
|
||
Comment on attachment 377425 [details] [diff] [review] Patch for nsIconChannel::GetHIconFromFile() ># HG changeset patch ># User kyle@kyle-laptop ># Date 1242317025 14400 ># Node ID 32f644221c8c2d5ec197fb5a8961fe5d2dc1a353 ># Parent f677422fdf56910731d45f6ed9430abc1bdb2206 >This patch fixes bug 415761 by making the internal string handling in >nsIconChannel::GetHIconFromFile() Unicode safe > >diff -r f677422fdf56 -r 32f644221c8c modules/libpr0n/decoders/icon/win/nsIconChannel.cpp >--- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp Thu May 14 16:17:53 2009 +0200 >+++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp Thu May 14 12:03:45 2009 -0400 >@@ -323,32 +323,33 @@ > NS_ENSURE_SUCCESS(rv, rv); > > // if the file exists, we are going to use it's real attributes...otherwise we only want to use it for it's extension... > SHFILEINFOW sfi; > UINT infoFlags = SHGFI_ICON; > > PRBool fileExists = PR_FALSE; > >- nsCAutoString filePath(fileExt); >+ nsAutoString filePath; >+ CopyASCIItoUTF16(fileExt, filePath); > if (localFile) > { > rv = localFile->Normalize(); > NS_ENSURE_SUCCESS(rv, rv); > >- localFile->GetNativePath(filePath); >+ localFile->GetPath(filePath); > if (filePath.Length() < 2 || filePath[1] != ':') > return NS_ERROR_MALFORMED_URI; // UNC > > if (filePath.Last() == ':') > filePath.Append('\\'); > else { > localFile->Exists(&fileExists); > if (!fileExists) >- localFile->GetNativeLeafName(filePath); >+ localFile->GetLeafName(filePath); > } > } > > if (!fileExists) > infoFlags |= SHGFI_USEFILEATTRIBUTES; > > infoFlags |= GetSizeInfoFlag(desiredImageSize); > >@@ -359,34 +360,34 @@ > nsCOMPtr<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); > NS_ENSURE_SUCCESS(rv, rv); > > nsCAutoString defFileExt; > mimeService->GetPrimaryExtension(contentType, fileExt, defFileExt); > // If the mime service does not know about this mime type, we show > // the generic icon. > // In any case, we need to insert a '.' before the extension. >- filePath = NS_LITERAL_CSTRING(".") + defFileExt; >+ filePath = NS_LITERAL_STRING(".") + NS_ConvertASCIItoUTF16(defFileExt); > } > > // Is this the "Desktop" folder? > DWORD shellResult = GetSpecialFolderIcon(localFile, CSIDL_DESKTOP, &sfi, infoFlags); > if (!shellResult) { > // Is this the "My Documents" folder? > shellResult = GetSpecialFolderIcon(localFile, CSIDL_PERSONAL, &sfi, infoFlags); > } > > // There are other "Special Folders" and Namespace entities that we are not > // fetching icons for, see: > // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp > // If we ever need to get them, code to do so would be inserted here. > > // Not a special folder, or something else failed above. > if (!shellResult) >- shellResult = ::SHGetFileInfoW(NS_ConvertUTF8toUTF16(filePath).get(), >+ shellResult = ::SHGetFileInfoW(filePath.get(), > FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags); > > if (shellResult && sfi.hIcon) > *hIcon = sfi.hIcon; > else > rv = NS_ERROR_NOT_AVAILABLE; > > return rv;
Attachment #377425 -
Attachment is obsolete: false
Assignee | ||
Updated•15 years ago
|
Attachment #377847 -
Attachment is obsolete: true
Attachment #377847 -
Flags: superreview?(vladimir)
Assignee | ||
Updated•15 years ago
|
Attachment #377425 -
Attachment is obsolete: true
Assignee | ||
Comment 23•15 years ago
|
||
OK I've cleaned up the string handling per Vladimir and Neil's suggestions.
Attachment #377906 -
Flags: superreview?(vladimir)
Attachment #377906 -
Flags: review+
Comment on attachment 377906 [details] [diff] [review] Patch nsIconChannel::GetHIconFromFile Looks fine, thanks; Neil's comments were correct, that's what I get for doing reviews right after waking up :)
Attachment #377906 -
Flags: superreview?(vladimir) → superreview+
Assignee | ||
Updated•15 years ago
|
Whiteboard: [needs landing]
Comment 25•15 years ago
|
||
(In reply to comment #24) > Neil's comments were correct, that's what I get for doing reviews right after waking up :) I have the opposite problem, I do reviews when I should have gone to sleep ;-)
Keywords: checkin-needed
Whiteboard: [needs landing]
Comment 26•15 years ago
|
||
Comment on attachment 377906 [details] [diff] [review] Patch nsIconChannel::GetHIconFromFile > else { > localFile->Exists(&fileExists); > if (!fileExists) >- localFile->GetNativeLeafName(filePath); >- } >+ localFile->GetLeafName(filePath); >+ } Nit: "}" should not move.
Updated•15 years ago
|
Keywords: checkin-needed
Whiteboard: [c-n: needs new patch]
Assignee | ||
Comment 27•15 years ago
|
||
Patch that doesn't screw with whitespacing.
Assignee | ||
Updated•15 years ago
|
Whiteboard: [c-n: needs new patch] → checkin-needed
http://hg.mozilla.org/mozilla-central/rev/3b4b7d84ee13 Thanks!
Whiteboard: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment 30•15 years ago
|
||
How to fix the problem? It appears at Firefox 3.5, and I don't know what to do. I have report the bug last day. https://bugzilla.mozilla.org/show_bug.cgi?id=501958
Comment 31•15 years ago
|
||
(In reply to comment #30) > How to fix the problem? > It appears at Firefox 3.5, and I don't know what to do. > I have report the bug last day. > https://bugzilla.mozilla.org/show_bug.cgi?id=501958 patch is not landed on 3.5 branch yet. so checkin needed
Reporter | ||
Comment 32•15 years ago
|
||
Afaik, this will not be fixed on the 3.5 branch, unless the patch gets approval for it.
Assignee | ||
Comment 33•15 years ago
|
||
Comment on attachment 385000 [details] [diff] [review] Patch w/nit Nominating for approval on 1.9.1 branch per requests. Patch adds Unicode support to nsIconChannel::GetHIconFromFile, resolving a number of visual bugs mostly in the Download Manager that result in the wrong or no icon being displayed when non-ASCII characters are involved on Windows. There is no anticipated risk; ASCII strings should pass through the modifications with no trouble, so there should be no regressions in functionality or performance. This has been on trunk for a few days and no complaints have been reported.
Attachment #385000 -
Flags: approval1.9.1?
Assignee | ||
Updated•15 years ago
|
Attachment #385000 -
Flags: approval1.9.1? → approval1.9.1.1?
Comment 36•15 years ago
|
||
Comment on attachment 385000 [details] [diff] [review] Patch w/nit Patch looks safe, but we need tests for it before we can consider it.
Attachment #385000 -
Flags: approval1.9.1.1? → approval1.9.1.1-
Updated•15 years ago
|
Flags: in-testsuite?
Comment 38•15 years ago
|
||
Attachment #390225 -
Flags: review?(jwalden+bmo)
Assignee | ||
Comment 39•15 years ago
|
||
With the accelerated schedule for 1.9.2 I'm inclined to believe that there is little point in taking this on branch.
Comment 40•15 years ago
|
||
Comment on attachment 390225 [details] [diff] [review] Reftest Rather than adding __LOCATION__ I'd prefer if you used the same methods as this test: http://mxr.mozilla.org/mozilla-central/source/content/media/test/contentDuration1.sjs I'm not sure whether I like the idea of __LOCATION__ or not, need to give it more thought; the above method should suffice for now. With that change all cool, I think.
Attachment #390225 -
Flags: review?(jwalden+bmo) → review+
Comment 41•15 years ago
|
||
Comment on attachment 390225 [details] [diff] [review] Reftest The whole idea of the review was to approve the creation of __LOCATION__, so if you don't want it then minus the patch.
Attachment #390225 -
Flags: review+ → review-
Updated•15 years ago
|
Target Milestone: --- → mozilla1.9.2a1
Comment 43•15 years ago
|
||
Attachment #425459 -
Flags: review?(jwalden+bmo)
Updated•15 years ago
|
Attachment #425459 -
Flags: review?(jwalden+bmo) → review+
Comment 44•15 years ago
|
||
Comment on attachment 425459 [details] [diff] [review] Alternative way of providing the location of the sjs file Pushed changeset f58bacef76d4 to mozilla-central.
Assignee | ||
Updated•15 years ago
|
Flags: in-testsuite? → in-testsuite+
You need to log in
before you can comment on or make changes to this bug.
Description
•