Closed
Bug 84160
Opened 23 years ago
Closed 23 years ago
Change in the way NPP_StreamAsFile Works: zero length string passed as URL
Categories
(Core Graveyard :: Plug-ins, defect, P1)
Tracking
(Not tracked)
VERIFIED
FIXED
mozilla0.9.2
People
(Reporter: arun, Assigned: peterl-bugs)
References
()
Details
(Whiteboard: rtm stopper)
Attachments
(3 files)
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review |
These are the relevant bug details. Note that although a workaround is
possible, namely: access NPStream's url field, it is a little kludgy and this in
general is a 4xp (4.x compatibility) issue with the Moz' compatible plugin API.
Comments from Eric Carlson:
The most serious bug for me is a change in the way that the
plug-in function NPP_StreamAsFile works. One of the parameters to the
function is a C string with the "file://" url the plug-in should
load. NS 3.0 sometimes passes a NULL for this param (apparently when
it doesn't like the url encoding), but NS 4.x always passes the
encoded url. NS 6 seems to always pass a zero length string for the
url (0 in the string's first byte), so the QuickTime plug-in fails to
load the file. The url _is_ in the NPStream's "url" field, but our
plug-in does not look there because all previous versions of NS (and
IE for that matter) pass it to the function directly.
Reporter | ||
Comment 1•23 years ago
|
||
peterl and shrir, given the extra engineering help, see if this ought to be a
branch check in (if possible). peterl may have bird in hand w.r.t a fix.
Keywords: 4xp
Priority: -- → P1
Comment 2•23 years ago
|
||
This is very easy to fix...a problem in our implmentation. I just need a
testcase or steps to reproduce to verify that I have indeed fixed this.
Status: NEW → ASSIGNED
Keywords: mozilla0.9.2,
testcase
Comment 3•23 years ago
|
||
Here's a starter patch:
ns4xPluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo,
const char* fileName)
{
if(!mInst || !mInst->IsStarted())
return NS_ERROR_FAILURE;
NPP npp;
const NPPluginFuncs *callbacks = nsnull;
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
if(!callbacks || !npp->pdata)
return NS_ERROR_FAILURE;
-
- pluginInfo->GetURL(&mNPStream.url);
+
+ pluginInfo->GetURL(&mNPStream.url);
+
+ if (mNPStream.url && !fileName)
+ fileName = PL_strcpy(mNPStream.url);
if (callbacks->asfile == NULL)
return NS_OK;
PRLibrary* lib = nsnull;
lib = mInst->fLibrary;
NS_TRY_SAFE_CALL_VOID(CallNPP_StreamAsFileProc(callbacks->asfile,
npp,
&mNPStream,
fileName), lib);
return NS_OK;
}
Reporter | ||
Comment 4•23 years ago
|
||
so there's a tad bit of redundancy, right? we returned the url in NPStream as
well as now directly via the function. i guess this is what 4.x did though.
Comment 5•23 years ago
|
||
This is an important API compatibility we need to fix for mozilla0.9.2
Target Milestone: --- → mozilla0.9.2
Comment 6•23 years ago
|
||
The following patch will fix the problem. It will also fix loading Acrobat file
locally from the hard drive through File | Open:
c:\Program Files\Adobe\Acrobat 4.0\Reader\readMe.pdf
I wish there was an easier way to do this. Any ideas?
Comment 7•23 years ago
|
||
Comment 9•23 years ago
|
||
Waterson, can I get a super review?
Whiteboard: [need r= sr= a=] → [need sr= a=]
Comment 10•23 years ago
|
||
General question: how does this fix the bug? Can you walk me through the problem?
Nits:
- You leak |fileName| when you go through the funky new logic you've added.
- Why do you QI() from nsIFile to nsILocalFile, and then back again to nsIFile?
I presume you're trying to figure out if |file| is-a nsILocalFile? But if so,
why do the extra QI() back? Why do you care if it's an nsILocalFile, anyway?
The method you want to call is on the nsIFile interface At a minimum, this
needs some serious commenting, because it's pretty zany.
- Place your variable declarations as close as possible to where they are
being used (e.g., |nsCOMPtr<nsIURI> uri| and |nsresult rv| can be nested
inside the first |if| block.
- Use NS_CONST_CAST() instead of C-style cast
Comment 11•23 years ago
|
||
Comment 12•23 years ago
|
||
I'm trying to convert a file://c|/temp string to a c:\temp string. I don't know
what I was thinking with all those extra QI's. And I think I plugged the leak.
Let me know what you think.
Comment 13•23 years ago
|
||
Ok, the new patch looks pretty good. Couple _more_ nits ;-)
- You don't need |PRBool createdHere|, because if
|fileName && fileName != aFileName|,
then you must've allocated it in |GetPath()|
- In this block:
+ nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri, &rv);
+ nsCOMPtr<nsIFile> file;
+ if (NS_SUCCEEDED(rv))
+ if (NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) && file)
You're a bit inconsistent about handling return codes. I'd personally find
this to be sufficient:
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri);
if (fileURL) {
nsCOMPtr<nsIFile> file;
fileURL->GetFile(getter_AddRefs(file));
if (file) {
...
}
}
because nsCOMPtr is known to initialize the pointer to 0. But, if you're
feeling ultra-paranoid, then maybe:
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri, &rv);
if (NS_SUCCEEDED(rv) && fileURL) {
...
}
to be consistent with the paranoia below? Heck, get rid of return code
paranoia! Just check the pointers to make sure they're non-zero! ;-)
(Actually, I don't really care if you make that change or not. It's
a stylistic thing, and the couple of extra instructions aren't going to
make or break us. It's your code. Go with whatever feels best to you.)
So, get rid of |createdHere|, and optionally do the other stuff, and sr=waterson.
Comment 14•23 years ago
|
||
Comment 15•23 years ago
|
||
This one-line solves the problem one method up the stack.
Comment 16•23 years ago
|
||
Boioioioing! Yeah, much nicer! (r|sr)=waterson, whichever helps.
Comment 17•23 years ago
|
||
Andrei or Doug, can I get your (r|sr)=?
Comment 18•23 years ago
|
||
Cool! r=av
Comment 19•23 years ago
|
||
a=dbaron for trunk checkin (on behalf of drivers)
Whiteboard: [need sr= a=]
Updated•23 years ago
|
Whiteboard: rtm stopper
Comment 20•23 years ago
|
||
Patch checked in, marking FIXED.
/cvsroot/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp
new revision: 1.261; previous revision: 1.260
Comment 21•23 years ago
|
||
really marking fixed this time.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Updated•3 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•