Closed
Bug 38094
Opened 25 years ago
Closed 25 years ago
nsPluginHostImpl::GetURL does not work for relative URLs if target is null
Categories
(Core Graveyard :: Plug-ins, defect, P3)
Core Graveyard
Plug-ins
Tracking
(Not tracked)
VERIFIED
FIXED
M16
People
(Reporter: sean, Assigned: serhunt)
Details
(Keywords: testcase, Whiteboard: [nsbeta2-])
Attachments
(2 files)
11.94 KB,
binary/zip
|
Details | |
4.44 KB,
patch
|
Details | Diff | Splinter Review |
A plugin calls nsIPluginManager::GetURL to programmatically load a URL. This
is implemented by nsPluginHostImpl::GetURL.
If the aTarget parameter of nsPluginHostImpl::GetURL is non-null, then the
request is passed off to nsPluginInstanceOwner::GetURL.
nsPluginInstanceOwner::GetURL creates an absolute URL from the owner's FullURL
and the requested (potentially relative) URL by way of NS_MakeAbsoluteURI().
If the aTarget parameter is null and streamListener is non-null, the call is
passed off to NewPluginURLStream(). NewPluginURLStream() does not turn a
relative URL into an absolute URL.
NewPluginURLStream() should do similar massaging of the requested URL as is
done at
http://lxr.mozilla.org/seamonkey/source/layout/html/base/src/nsObjectFrame.cpp#1
631.
Reporter | ||
Comment 1•25 years ago
|
||
Something along these lines - just don't know how to get the owner's full URL -
see the TODO (sorry about line wraps):
NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
nsIPluginInstance *aInstance,
nsIPluginStreamListener* aListener)
{
nsIURI *url;
nsAutoString fullurl; fullurl.Assign(aURL);
nsPluginStreamListenerPeer *listenerPeer = (nsPluginStreamListenerPeer *)new
nsPluginStreamListenerPeer();
if (listenerPeer == NULL)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
if (aURL.Length() <= 0)
return NS_OK;
nsPluginInstancePeerImpl *peer;
rv = aInstance->GetPeer((nsIPluginInstancePeer **)&peer);
if (NS_OK == rv)
{
nsIPluginInstanceOwner *owner;
rv = peer->GetOwner(owner);
if (NS_OK == rv)
{
nsAutoString uniurl; uniurl.Assign(aURL);
nsIURI* baseURL;
// TODO: get Full URL from owner or from owner's owner
// owner->mOwner->GetFullURL(baseURL);
// Create an absolute URL
rv = NS_MakeAbsoluteURI(fullurl, uniurl, baseURL);
NS_IF_RELEASE(baseURL);
NS_RELEASE(owner);
}
NS_RELEASE(peer);
}
rv = NS_NewURI(&url, fullurl);
Reporter | ||
Comment 2•25 years ago
|
||
This takes care of it:
NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
nsIPluginInstance *aInstance,
nsIPluginStreamListener* aListener)
{
nsIURI *url;
nsAutoString absUrl; absUrl.Assign(aURL);
nsPluginStreamListenerPeer *listenerPeer = (nsPluginStreamListenerPeer *)new
nsPluginStreamListenerPeer();
if (listenerPeer == NULL)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;
if (aURL.Length() <= 0)
return NS_OK;
// get the full URL of the document that the plugin is embedded
// in to create an absolute url in case aURL is relative
nsPluginInstancePeerImpl *peer;
rv = aInstance->GetPeer((nsIPluginInstancePeer **)&peer);
if (NS_OK == rv)
{
nsIPluginInstanceOwner *owner;
rv = peer->GetOwner(owner);
if (NS_OK == rv)
{
nsCOMPtr<nsIDocument> doc;
rv = owner->GetDocument(getter_AddRefs(doc));
if (NS_OK == rv)
{
nsCOMPtr<nsIURI> docURL( dont_AddRef(doc-
>GetDocumentURL()) );
// Create an absolute URL
rv = NS_MakeAbsoluteURI(absUrl, aURL, docURL);
}
NS_RELEASE(owner);
}
NS_RELEASE(peer);
}
rv = NS_NewURI(&url, absUrl);
Reporter | ||
Comment 4•25 years ago
|
||
Reporter | ||
Comment 5•25 years ago
|
||
In the previously attached npsimple.cpp, go to line 935 for comments that
explain the problem. Load the html file included in the zip using file: if you
don't have the xpconnect plugin security work-around. Enter the relative path
of a file you'd like the plugin to attempt to download. Trace the calls into
GetURL per the comments. NewPluginURLStream fails if the path is relative. It
works if it's absolute.
Reporter | ||
Updated•25 years ago
|
*** Bug 42039 has been marked as a duplicate of this bug. ***
Reporter | ||
Comment 8•25 years ago
|
||
nominating nsbeta2 so that the patch can be checked in and so that xpcom
plugins can be tested using an unmodified PR2 release.
Keywords: nsbeta2
Comment 9•25 years ago
|
||
nsbeta2-, but you can still checkin patches from external contributors with
proper review and approval from module owner and brendan/waterson.
Whiteboard: [nsbeta2-]
Reporter | ||
Comment 10•25 years ago
|
||
Reporter | ||
Comment 11•25 years ago
|
||
Added up to date patch. It has a few more changes than the original patch:
- moved a printf inside a #ifdef NS_DEBUG
- made changes to my patch per comments received
- applied changes to the places I copied code from
- address potential leak of nsPluginStreamListenerPeer *listenerPeer in
nsPluginHostImpl::NewPluginURLStream()
Assignee | ||
Comment 12•25 years ago
|
||
What should we do to get it in?
Comment 13•25 years ago
|
||
Looks good to me -- ra=brendan@mozilla.org.
av, can you get this checked in?
/be
Assignee | ||
Comment 14•25 years ago
|
||
Checked in. Marking fixed. Thanks, Sean.
Status: ASSIGNED → RESOLVED
Closed: 25 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
•