Closed
Bug 308305
Opened 19 years ago
Closed 19 years ago
implement nsIFileProtocolHandler::ReadURLFile for GNOME
Categories
(Core :: Networking: File, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: chpe, Assigned: chpe)
References
()
Details
Attachments
(1 file, 2 obsolete files)
|
2.48 KB,
patch
|
Biesinger
:
review+
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
Bug 69114 added ReadURLFile to read windows link files, and bug 287603 implemented it for OS/2. What's missing is an implementation of ReadURLFile for GNOME/KDE-style .desktop files [http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-0.9.4.html]. What we're interested in here is .desktop files with Type=Link. Steps to reproduce: 0) Open a web page in firefox 1) Drag a link to your GNOME desktop 2) Drag the newly created object from desktop into the browser Results: Tries to open the .desktop file with an external program, instead of loading the link contained in the file. Remaining problems with the patch: - the URL bar will show the file:// URL of the dragged .desktop file instead of the loaded page URL. This seems to be a problem somewhere in docshell? - it only works if you drag .desktop from file:/// not from arbitrary gnome-vfs locations
| Assignee | ||
Comment 1•19 years ago
|
||
Comment 2•19 years ago
|
||
Comment on attachment 195856 [details] [diff] [review] proposed fix biesi: can you do first review on this? thx!
Attachment #195856 -
Flags: review?(cbiesinger)
Updated•19 years ago
|
Comment 3•19 years ago
|
||
Comment on attachment 195856 [details] [diff] [review] proposed fix + nsresult rv; + nsCAutoString leafName; + rv = aFile->GetNativeLeafName(leafName); please move the rv declaration to the line where it's first used Hmm, I wonder why URLs are defined to be ASCII-only... thanks for doing this. r=biesi
Attachment #195856 -
Flags: review?(cbiesinger) → review+
Comment 5•19 years ago
|
||
Comment on attachment 195881 [details] [diff] [review] updated patch with change requested by the reviewer >Index: netwerk/protocol/file/src/nsFileProtocolHandler.cpp >+ !StringEndsWith(leafName, NS_LITERAL_CSTRING(".desktop"), >+ nsCaseInsensitiveCStringComparator())) case insensitive really? is there by chance a specification somewhere that you can link to in the code? a comment with an URL would be nice. >+ nsCOMPtr<nsILocalFile> file(do_QueryInterface(aFile, &rv)); >+ if (NS_FAILED(rv)) >+ return NS_ERROR_NOT_AVAILABLE; >+ >+ nsINIParser parser; >+ rv = parser.Init(file); >+ if (NS_FAILED(rv)) >+ return NS_ERROR_NOT_AVAILABLE; It's generally better to propogate error codes unless there is good reason to map them all to one error code like this. The API says: * @throw NS_ERROR_NOT_AVAILABLE if the OS does not support such files. * @throw NS_ERROR_NOT_AVAILABLE if this file is not an internet shortcut. I don't think failure for nsIFile to QI to nsILocalFile is covered by either of those cases, so I would just propogate |rv|. Same goes for nsINIParser::Init failing.
Attachment #195881 -
Flags: superreview-
| Assignee | ||
Comment 6•19 years ago
|
||
(In reply to comment #5) > (From update of attachment 195881 [details] [diff] [review] [edit]) > >Index: netwerk/protocol/file/src/nsFileProtocolHandler.cpp > > >+ !StringEndsWith(leafName, NS_LITERAL_CSTRING(".desktop"), > >+ nsCaseInsensitiveCStringComparator())) > > case insensitive really? is there by chance a specification somewhere > that you can link to in the code? a comment with an URL would be nice. http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-0.9.4.html#basic-format says: " These desktop entry files should have the extension .desktop. Determining file type on basis of extension makes determining the file type very easy and quick. When no file extension is present, the desktop system should fall back to recognition via "magic detection"." I talked with biesi about this on irc, and we agreed that it would be okay to support only files with the extension, without doing the magic detection. I could check it case insensitively though, if you think checking only lowercase might be a problem? Like this: nsAutoString path; nsresult rv = aFile->GetPath(path); if (NS_FAILED(rv)) return rv; if (path.Length() < 9) return NS_ERROR_NOT_AVAILABLE; if (!StringTail(path, 8).LowerCaseEqualsLiteral(".desktop")) return NS_ERROR_NOT_AVAILABLE; > It's generally better to propogate error codes unless there is good > reason to map them all to one error code like this. The API says: > > * @throw NS_ERROR_NOT_AVAILABLE if the OS does not support such files. > * @throw NS_ERROR_NOT_AVAILABLE if this file is not an internet shortcut. > > I don't think failure for nsIFile to QI to nsILocalFile is covered > by either of those cases, so I would just propogate |rv|. Same goes > for nsINIParser::Init failing. Fixed in my tree. (In reply to comment #3) > Hmm, I wonder why URLs are defined to be ASCII-only... Interestingly, Nautilus already creates .desktop files with UTF-8 in the URL field, for example when I drag a link to a non-punycoded IDN domain... It could be an oversight, I'll ask the relevant list [http://freedesktop.org/mailman/listinfo/xdg] .
| Assignee | ||
Comment 7•19 years ago
|
||
Changed to check for ".desktop" extension case-sensitively, and to propagate return value. Add a link to the spec in a comment.
Attachment #195881 -
Attachment is obsolete: true
| Assignee | ||
Updated•19 years ago
|
Attachment #195917 -
Flags: superreview?(darin)
Attachment #195917 -
Flags: review?(cbiesinger)
Comment 8•19 years ago
|
||
Comment on attachment 195917 [details] [diff] [review] updated patch Looks good to me, sr=darin
Attachment #195917 -
Flags: superreview?(darin) → superreview+
Updated•19 years ago
|
Attachment #195917 -
Flags: review?(cbiesinger) → review+
Updated•19 years ago
|
Assignee: darin → chpe
Comment 9•19 years ago
|
||
Checking in netwerk/protocol/file/src/nsFileProtocolHandler.cpp; /cvsroot/mozilla/netwerk/protocol/file/src/nsFileProtocolHandler.cpp,v <-- nsFileProtocolHandler.cpp new revision: 1.65; previous revision: 1.64 done
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 10•19 years ago
|
||
I filed bug 309781 as follow-up for the problem with the location bar that was mentioned in comment 0.
You need to log in
before you can comment on or make changes to this bug.
Description
•