OP_STATUS DecodedMIME_Storage::Construct(URL_Rep *url_rep) { #ifdef URL_SEPARATE_MIME_URL_NAMESPACE URL parentURL(url_rep, (char*)NULL); if (urlManager->FindContextIdByParentURL(parentURL, context_id) == FALSE) { context_id = urlManager->GetNewContextID(); TRAPD(op_err, urlManager->AddContextL(context_id, OPFILE_ABSOLUTE_FOLDER, OPFILE_ABSOLUTE_FOLDER, OPFILE_ABSOLUTE_FOLDER, OPFILE_ABSOLUTE_FOLDER, parentURL, TRUE)); if(OpStatus::IsError(op_err)) context_id = 0; } else { Context_Manager *cm = urlManager->FindContextManager(context_id); if(cm) cm->FreeUnusedResources(TRUE); } URL base_alias = urlManager->GetURL(url_rep->GetAttribute(URL::KName_Username_Password_Escaped_NOT_FOR_UI).CStr(), context_id); TRAPD(op_err, url_rep->SetAttributeL(URL::KBaseAliasURL, base_alias)); #endif #ifdef RAMCACHE_ONLY return OpStatus::OK; #else return Decode_Storage::Construct(url_rep); #endif }
QUrl ScriptEngine::resolveInclude(const QString& include) const { // first lets check to see if it's already a full URL QUrl url(include); if (!url.scheme().isEmpty()) { return url; } // we apparently weren't a fully qualified url, so, let's assume we're relative // to the original URL of our script QUrl parentURL(_fileNameString); // if the parent URL's scheme is empty, then this is probably a local file... if (parentURL.scheme().isEmpty()) { parentURL = QUrl::fromLocalFile(_fileNameString); } // at this point we should have a legitimate fully qualified URL for our parent url = parentURL.resolved(url); return url; }
nsresult nsFrameLoader::CheckForRecursiveLoad(nsIURI* aURI) { mDepthTooGreat = PR_FALSE; nsresult rv = EnsureDocShell(); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell); NS_ASSERTION(treeItem, "docshell must be a treeitem!"); PRInt32 ourType; rv = treeItem->GetItemType(&ourType); if (NS_SUCCEEDED(rv) && ourType != nsIDocShellTreeItem::typeContent) { // No need to do recursion-protection here XXXbz why not?? Do we really // trust people not to screw up with non-content docshells? return NS_OK; } // Bug 8065: Don't exceed some maximum depth in content frames // (MAX_DEPTH_CONTENT_FRAMES) nsCOMPtr<nsIDocShellTreeItem> parentAsItem; treeItem->GetSameTypeParent(getter_AddRefs(parentAsItem)); PRInt32 depth = 0; while (parentAsItem) { ++depth; if (depth >= MAX_DEPTH_CONTENT_FRAMES) { mDepthTooGreat = PR_TRUE; NS_WARNING("Too many nested content frames so giving up"); return NS_ERROR_UNEXPECTED; // Too deep, give up! (silently?) } nsCOMPtr<nsIDocShellTreeItem> temp; temp.swap(parentAsItem); temp->GetSameTypeParent(getter_AddRefs(parentAsItem)); } // Bug 136580: Check for recursive frame loading // pre-grab these for speed nsCOMPtr<nsIURI> cloneURI; rv = aURI->Clone(getter_AddRefs(cloneURI)); NS_ENSURE_SUCCESS(rv, rv); // Bug 98158/193011: We need to ignore data after the # nsCOMPtr<nsIURL> cloneURL(do_QueryInterface(cloneURI)); // QI can fail if (cloneURL) { rv = cloneURL->SetRef(EmptyCString()); NS_ENSURE_SUCCESS(rv,rv); } PRInt32 matchCount = 0; treeItem->GetSameTypeParent(getter_AddRefs(parentAsItem)); while (parentAsItem) { // Check the parent URI with the URI we're loading nsCOMPtr<nsIWebNavigation> parentAsNav(do_QueryInterface(parentAsItem)); if (parentAsNav) { // Does the URI match the one we're about to load? nsCOMPtr<nsIURI> parentURI; parentAsNav->GetCurrentURI(getter_AddRefs(parentURI)); if (parentURI) { nsCOMPtr<nsIURI> parentClone; rv = parentURI->Clone(getter_AddRefs(parentClone)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIURL> parentURL(do_QueryInterface(parentClone)); if (parentURL) { rv = parentURL->SetRef(EmptyCString()); NS_ENSURE_SUCCESS(rv,rv); } PRBool equal; rv = cloneURI->Equals(parentClone, &equal); NS_ENSURE_SUCCESS(rv, rv); if (equal) { matchCount++; if (matchCount >= MAX_SAME_URL_CONTENT_FRAMES) { NS_WARNING("Too many nested content frames have the same url (recursion?) so giving up"); return NS_ERROR_UNEXPECTED; } } } } nsCOMPtr<nsIDocShellTreeItem> temp; temp.swap(parentAsItem); temp->GetSameTypeParent(getter_AddRefs(parentAsItem)); } return NS_OK; }