diff --git a/mozilla/content/base/src/nsContentAreaDragDrop.cpp b/mozilla/content/base/src/nsContentAreaDragDrop.cpp index e0621e4be14..1c3e4f02685 100644 --- a/mozilla/content/base/src/nsContentAreaDragDrop.cpp +++ b/mozilla/content/base/src/nsContentAreaDragDrop.cpp @@ -73,7 +73,7 @@ #include "nsISupportsPrimitives.h" #include "nsIServiceManagerUtils.h" #include "nsPromiseFlatString.h" -#include "nsNetUtil.h" +#include "nsIIOService.h" #include "nsIFile.h" #include "nsIWebNavigation.h" #include "nsIDragDropOverride.h" @@ -313,12 +313,13 @@ nsContentAreaDragDrop::ExtractURLFromData(const nsACString & inFlavor, nsISuppor } } else if ( inFlavor.Equals(kFileMime) ) { - // the data is a file. Use the necko parsing utils to get a file:// url + // the data is a file. Use the IOService to get a file:// url // from the OS data. + nsCOMPtr ioService(do_GetService("@mozilla.org/network/io-service;1")); nsCOMPtr file(do_QueryInterface(inDataWrapper)); - if ( file ) { + if ( ioService && file ) { nsCAutoString url; - NS_GetURLSpecFromFile(file, url); + ioService->GetURLSpecFromFile(file, url); outURL = NS_ConvertUTF8toUCS2(url); } } diff --git a/mozilla/editor/ui/composer/content/editorUtilities.js b/mozilla/editor/ui/composer/content/editorUtilities.js index 13c00f11a63..dfcd1c2823c 100644 --- a/mozilla/editor/ui/composer/content/editorUtilities.js +++ b/mozilla/editor/ui/composer/content/editorUtilities.js @@ -485,8 +485,8 @@ function MakeRelativeUrl(url) // Get just the file path part of the urls - var docPath = IOService.newURI(docUrl, null, null).path; - var urlPath = IOService.newURI(inputUrl, null, null).path; + var docPath = IOService.extractUrlPart(docUrl, IOService.url_Path); + var urlPath = IOService.extractUrlPart(inputUrl, IOService.url_Path); // We only return "urlPath", so we can convert // the entire docPath for case-insensitive comparisons @@ -653,9 +653,9 @@ function GetDocumentUrl() } // Extract the scheme (e.g., 'file', 'http') from a URL string -function GetScheme(urlspec) +function GetScheme(url) { - var resultUrl = TrimString(urlspec); + var resultUrl = TrimString(url); // Unsaved document URL has no acceptable scheme yet if (!resultUrl || IsUrlAboutBlank(resultUrl)) return ""; @@ -670,13 +670,13 @@ function GetScheme(urlspec) var scheme = ""; try { // This fails if there's no scheme - scheme = IOService.extractScheme(resultUrl); + scheme = IOService.extractScheme(resultUrl, {schemeStartPos:0}, {schemeEndPos:0}); } catch (e) {} return scheme ? scheme.toLowerCase() : ""; } -function GetHost(urlspec) +function GetHost(url) { if (!url) return ""; @@ -687,13 +687,13 @@ function GetHost(urlspec) var host = ""; try { - host = IOService.newURI(urlspec, null, null).host; + host = IOService.extractUrlPart(url, IOService.url_Host); } catch (e) {} return host; } -function GetUsername(urlspec) +function GetUsername(url) { if (!url) return ""; @@ -704,15 +704,15 @@ function GetUsername(urlspec) var username = ""; try { - username = IOService.newURI(urlspec, null, null).username; + username = IOService.extractUrlPart(url, IOService.url_Username); } catch (e) {} return username; } -function GetFilename(urlspec) +function GetFilename(url) { - if (!urlspec || IsUrlAboutBlank(urlspec)) + if (!url || IsUrlAboutBlank(url)) return ""; var IOService = GetIOService(); @@ -722,12 +722,12 @@ function GetFilename(urlspec) var filename; try { - uri = IOService.newURI(urlspec, null, null); - if (uri) + filename = IOService.extractUrlPart(url, IOService.url_FileBaseName); + if (filename) { - var url = uri.QueryInterface(Components.interfaces.nsIURL); - if (url) - filename = url.fileName; + var ext = IOService.extractUrlPart(url, IOService.url_FileExtension); + if (ext) + filename += "."+ext; } } catch (e) {} @@ -737,11 +737,11 @@ function GetFilename(urlspec) // Return the url without username and password // Optional output objects return extracted username and password strings // This uses just string routines via nsIIOServices -function StripUsernamePassword(urlspec, usernameObj, passwordObj) +function StripUsernamePassword(url, usernameObj, passwordObj) { - urlspec = TrimString(urlspec); - if (!urlspec || IsUrlAboutBlank(urlspec)) - return urlspec; + url = TrimString(url); + if (!url || IsUrlAboutBlank(url)) + return url; if (usernameObj) usernameObj.value = ""; @@ -749,17 +749,16 @@ function StripUsernamePassword(urlspec, usernameObj, passwordObj) passwordObj.value = ""; // "@" must exist else we will never detect username or password - var atIndex = urlspec.indexOf("@"); + var atIndex = url.indexOf("@"); if (atIndex > 0) { try { var IOService = GetIOService(); if (!IOService) - return urlspec; + return url; - var uri = IOService.newURI(urlspec, null, null); - var username = uri.username; - var password = uri.password; + var username = IOService.extractUrlPart(url, IOService.url_Username); + var password = IOService.extractUrlPart(url, IOService.url_Password); if (usernameObj && username) usernameObj.value = username; @@ -767,79 +766,79 @@ function StripUsernamePassword(urlspec, usernameObj, passwordObj) passwordObj.value = password; if (username) { - var usernameStart = urlspec.indexOf(username); + var usernameStart = url.indexOf(username); if (usernameStart != -1) - return urlspec.slice(0, usernameStart) + urlspec.slice(atIndex+1); + return url.slice(0, usernameStart) + url.slice(atIndex+1); } } catch (e) {} } - return urlspec; + return url; } -function StripPassword(urlspec, passwordObj) +function StripPassword(url, passwordObj) { - urlspec = TrimString(urlspec); - if (!urlspec || IsUrlAboutBlank(urlspec)) - return urlspec; + url = TrimString(url); + if (!url || IsUrlAboutBlank(url)) + return url; if (passwordObj) passwordObj.value = ""; // "@" must exist else we will never detect password - var atIndex = urlspec.indexOf("@"); + var atIndex = url.indexOf("@"); if (atIndex > 0) { try { var IOService = GetIOService(); if (!IOService) - return urlspec; + return url; - var password = IOService.newURI(urlspec, null, null).password; + var password = IOService.extractUrlPart(url, IOService.url_Password); if (passwordObj && password) passwordObj.value = password; if (password) { // Find last ":" before "@" - var colon = urlspec.lastIndexOf(":", atIndex); + var colon = url.lastIndexOf(":", atIndex); if (colon != -1) { // Include the "@" - return urlspec.slice(0, colon) + urlspec.slice(atIndex); + return url.slice(0, colon) + url.slice(atIndex); } } } catch (e) {} } - return urlspec; + return url; } // Version to use when you have an nsIURI object function StripUsernamePasswordFromURI(uri) { - var urlspec = ""; + var url = ""; if (uri) { try { - urlspec = uri.spec; + url = uri.spec; var userPass = uri.userPass; if (userPass) { - start = urlspec.indexOf(userPass); - urlspec = urlspec.slice(0, start) + urlspec.slice(start+userPass.length+1); + start = url.indexOf(userPass); + url = url.slice(0, start) + url.slice(start+userPass.length+1); } } catch (e) {} } - return urlspec; + return url; } -function InsertUsernameIntoUrl(urlspec, username) +function InsertUsernameIntoUrl(url, username) { - if (!urlspec || !username) - return urlspec; + if (!url || !username) + return url; try { var ioService = GetIOService(); - var URI = ioService.newURI(urlspec, window.editorShell.GetDocumentCharacterSet(), null); + var URI = ioService.newURI(url, window.editorShell.GetDocumentCharacterSet(), null); URI.username = username; return URI.spec; } catch (e) {} diff --git a/mozilla/extensions/cookie/nsCookies.cpp b/mozilla/extensions/cookie/nsCookies.cpp index e153eadc36a..05659a7da32 100644 --- a/mozilla/extensions/cookie/nsCookies.cpp +++ b/mozilla/extensions/cookie/nsCookies.cpp @@ -1306,6 +1306,7 @@ cookie_SetCookieString(nsIURI * curURL, nsIPrompt *aPrompter, const char * setCo } /* generate the message for the nag box */ + PRUnichar * new_string=0; int count = cookie_Count(host_from_header); prev_cookie = cookie_CheckForPrevCookie (path_from_header, host_from_header, name_from_header); @@ -1494,8 +1495,9 @@ COOKIE_SetCookieStringFromHttp(nsIURI * curURL, nsIURI * firstURL, nsIPrompt *aP status = cookie_P3PDecision(curURL, firstURL, aHttpChannel); if (status == nsICookie::STATUS_REJECTED) { nsCOMPtr os(do_GetService("@mozilla.org/observer-service;1")); - if (os) - os->NotifyObservers(nsnull, "cookieIcon", NS_ConvertASCIItoUCS2("on").get()); + if (os) { + nsresult rv = os->NotifyObservers(nsnull, "cookieIcon", NS_ConvertASCIItoUCS2("on").get()); + } return; } } @@ -1655,7 +1657,7 @@ COOKIE_Read() { } cookie_CookieStruct *new_cookie, *tmp_cookie_ptr; size_t new_len; - nsCAutoString buffer; + nsAutoString buffer; PRBool added_to_list; nsFileSpec dirSpec; nsresult rv = CKutil_ProfileDirectory(dirSpec); @@ -1682,7 +1684,7 @@ COOKIE_Read() { added_to_list = PR_FALSE; if ( !buffer.IsEmpty() ) { - char firstChar = buffer.CharAt(0); + PRUnichar firstChar = buffer.CharAt(0); if (firstChar == '#' || firstChar == nsCRT::CR || firstChar == nsCRT::LF || firstChar == 0) { continue; @@ -1698,7 +1700,7 @@ COOKIE_Read() { (cookieIndex=buffer.FindChar('\t', nameIndex)+1) == 0 ) { continue; } - nsCAutoString host, isDomain, path, isSecure, expires, name, cookie; + nsAutoString host, isDomain, path, isSecure, expires, name, cookie; buffer.Mid(host, hostIndex, isDomainIndex-hostIndex-1); buffer.Mid(isDomain, isDomainIndex, pathIndex-isDomainIndex-1); buffer.Mid(path, pathIndex, secureIndex-pathIndex-1); @@ -1718,12 +1720,12 @@ COOKIE_Read() { new_cookie->cookie = ToNewCString(cookie); new_cookie->host = ToNewCString(host); new_cookie->path = ToNewCString(path); - if (isDomain.Equals(NS_LITERAL_CSTRING("TRUE"))) { + if (isDomain.Equals(NS_LITERAL_STRING("TRUE"))) { new_cookie->isDomain = PR_TRUE; } else { new_cookie->isDomain = PR_FALSE; } - if (isSecure.Equals(NS_LITERAL_CSTRING("TRUE"))) { + if (isSecure.Equals(NS_LITERAL_STRING("TRUE"))) { new_cookie->isSecure = PR_TRUE; } else { new_cookie->isSecure = PR_FALSE; @@ -1902,12 +1904,17 @@ COOKIE_Remove (PL_strcmp(cookie->name, name) == 0) && (PL_strcmp(cookie->path, path) == 0)) { if (blocked && cookie->host) { + char * hostname = nsnull; char * hostnameAfterDot = cookie->host; while (*hostnameAfterDot == '.') { hostnameAfterDot++; } - if (NS_SUCCEEDED(PERMISSION_Read())) - Permission_AddHost(nsDependentCString(hostnameAfterDot), PR_FALSE, COOKIEPERMISSION, PR_TRUE); + CKutil_StrAllocCopy(hostname, hostnameAfterDot); + if (hostname) { + if (NS_SUCCEEDED(PERMISSION_Read())) { + Permission_AddHost(hostname, PR_FALSE, COOKIEPERMISSION, PR_TRUE); + } + } } cookie_list->RemoveElementAt(count); deleteCookie((void*)cookie, nsnull); diff --git a/mozilla/extensions/cookie/nsIImgManager.idl b/mozilla/extensions/cookie/nsIImgManager.idl index 0b716326ecf..5c89972299e 100644 --- a/mozilla/extensions/cookie/nsIImgManager.idl +++ b/mozilla/extensions/cookie/nsIImgManager.idl @@ -44,12 +44,10 @@ #include "nsISupports.idl" -interface nsIURI; - [scriptable, uuid(D60B3710-166D-11d5-A542-0010A401EB10)] interface nsIImgManager : nsISupports { - void block(in nsIURI imageURL); + void block(in string imageURL); }; %{ C++ diff --git a/mozilla/extensions/cookie/nsIPermissionManager.idl b/mozilla/extensions/cookie/nsIPermissionManager.idl index de0ecd660d2..139077e7c1f 100644 --- a/mozilla/extensions/cookie/nsIPermissionManager.idl +++ b/mozilla/extensions/cookie/nsIPermissionManager.idl @@ -48,11 +48,11 @@ [scriptable, uuid(4F6B5E00-0C36-11d5-A535-0010A401EB10)] interface nsIPermissionManager : nsISupports { - void add(in AUTF8String objectURL, in boolean permission, in PRInt32 type); - boolean testForBlocking(in AUTF8String objectURL, in PRInt32 type); + void add(in string objectURL, in boolean permission, in PRInt32 type); + boolean testForBlocking(in string objectURL, in PRInt32 type); void removeAll(); readonly attribute nsISimpleEnumerator enumerator; - void remove(in AUTF8String host, in PRInt32 type); + void remove(in string host, in PRInt32 type); }; %{ C++ diff --git a/mozilla/extensions/cookie/nsImages.cpp b/mozilla/extensions/cookie/nsImages.cpp index c01b208e3a7..8e20aa780c5 100644 --- a/mozilla/extensions/cookie/nsImages.cpp +++ b/mozilla/extensions/cookie/nsImages.cpp @@ -45,7 +45,6 @@ #include "nsIPref.h" #include "nsIServiceManager.h" #include "nsIIOService.h" -#include "nsIURI.h" #define image_behaviorPref "network.image.imageBehavior" #define image_warningPref "network.image.warnAboutImages" @@ -211,13 +210,17 @@ IMAGE_BlockedInMail() } PUBLIC nsresult -IMAGE_Block(nsIURI* imageURI) -{ - if (!imageURI) { +IMAGE_Block(const char* imageURL, + nsIIOService* ioService) { + if (!imageURL || !(*imageURL)) { return NS_ERROR_NULL_POINTER; } - nsCAutoString hostPort; - imageURI->GetHostPort(hostPort); - Permission_AddHost(hostPort, PR_FALSE, IMAGEPERMISSION, PR_TRUE); + nsresult rv = NS_OK; + nsCAutoString host; + NS_ASSERTION(ioService, "IOService not available"); + rv = ioService->ExtractUrlPart(nsDependentCString(imageURL), + nsIIOService::url_Host | + nsIIOService::url_Port, host); + Permission_AddHost((char*)host.get(), PR_FALSE, IMAGEPERMISSION, PR_TRUE); return NS_OK; } diff --git a/mozilla/extensions/cookie/nsImages.h b/mozilla/extensions/cookie/nsImages.h index f5008084d72..a6ecf84fb43 100644 --- a/mozilla/extensions/cookie/nsImages.h +++ b/mozilla/extensions/cookie/nsImages.h @@ -41,12 +41,10 @@ #include "nsString.h" -class nsIURI; - extern nsresult IMAGE_CheckForPermission (const char * hostname, const char * firstHostname, PRBool *permission); extern PRBool IMAGE_BlockedInMail(void); -extern nsresult IMAGE_Block(nsIURI * imageURI); +extern nsresult IMAGE_Block(const char * imageURL, nsIIOService *ioService); extern void IMAGE_RegisterPrefCallbacks(void); #endif /* IMAGES_H */ diff --git a/mozilla/extensions/cookie/nsImgManager.cpp b/mozilla/extensions/cookie/nsImgManager.cpp index 17db610324f..856d052e059 100644 --- a/mozilla/extensions/cookie/nsImgManager.cpp +++ b/mozilla/extensions/cookie/nsImgManager.cpp @@ -92,9 +92,9 @@ nsresult nsImgManager::Init() } -NS_IMETHODIMP nsImgManager::Block(nsIURI* imageURI) +NS_IMETHODIMP nsImgManager::Block(const char * imageURL) { - ::IMAGE_Block(imageURI); + ::IMAGE_Block(imageURL,mIOService); return NS_OK; } diff --git a/mozilla/extensions/cookie/nsPermissionManager.cpp b/mozilla/extensions/cookie/nsPermissionManager.cpp index 1a16abcdc17..d7e548d6987 100644 --- a/mozilla/extensions/cookie/nsPermissionManager.cpp +++ b/mozilla/extensions/cookie/nsPermissionManager.cpp @@ -47,7 +47,7 @@ #include "nsIPrompt.h" #include "nsIObserverService.h" #include "nsPermission.h" -#include "nsNetUtil.h" +#include "nsNetCID.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -129,26 +129,19 @@ nsresult nsPermissionManager::Init() observerService->AddObserver(this, "profile-before-change", PR_FALSE); observerService->AddObserver(this, "profile-do-change", PR_FALSE); } - - mIOService = do_GetIOService(); + mIOService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); return rv; } NS_IMETHODIMP nsPermissionManager::Add - (const nsACString & objectURI, PRBool permission, PRInt32 type) { - // XXX ideally we should change this interface to pass nsIURI - nsCOMPtr uri; - NS_NewURI(getter_AddRefs(uri), objectURI, nsnull, nsnull, mIOService); - ::PERMISSION_Add(uri, permission, type); + (const char * objectURL, PRBool permission, PRInt32 type) { + ::PERMISSION_Add(objectURL, permission, type, mIOService); return NS_OK; } NS_IMETHODIMP nsPermissionManager::TestForBlocking - (const nsACString &objectURI, PRInt32 type, PRBool* blocked) { - // XXX ideally we should change this interface to pass nsIURI - nsCOMPtr uri; - NS_NewURI(getter_AddRefs(uri), objectURI, nsnull, nsnull, mIOService); - ::PERMISSION_TestForBlocking(uri, blocked, type); + (const char * objectURL, PRInt32 type, PRBool* blocked) { + ::PERMISSION_TestForBlocking(objectURL, blocked, type, mIOService); return NS_OK; } @@ -169,7 +162,7 @@ NS_IMETHODIMP nsPermissionManager::GetEnumerator(nsISimpleEnumerator * *entries) return NS_OK; } -NS_IMETHODIMP nsPermissionManager::Remove(const nsACString & host, PRInt32 type) { +NS_IMETHODIMP nsPermissionManager::Remove(const char* host, PRInt32 type) { ::PERMISSION_Remove(host, type); return NS_OK; } diff --git a/mozilla/extensions/cookie/nsPermissions.cpp b/mozilla/extensions/cookie/nsPermissions.cpp index 8e6b62455d3..fd2d4d78460 100644 --- a/mozilla/extensions/cookie/nsPermissions.cpp +++ b/mozilla/extensions/cookie/nsPermissions.cpp @@ -50,7 +50,7 @@ #include "nsVoidArray.h" #include "prmem.h" #include "nsAppDirectoryServiceDefs.h" -#include "nsIURI.h" +#include "nsIIOService.h" #include "nsNetCID.h" #include "nsTextFormatter.h" @@ -212,12 +212,14 @@ Permission_Check( /* see if we need to remember this decision */ if (rememberChecked) { + char * hostname2 = NULL; /* ignore leading periods in host name */ const char * hostnameAfterDot = hostname; while (hostnameAfterDot && (*hostnameAfterDot == '.')) { hostnameAfterDot++; } - Permission_AddHost(nsDependentCString(hostnameAfterDot), permission, type, PR_TRUE); + CKutil_StrAllocCopy(hostname2, hostnameAfterDot); + Permission_AddHost(hostname2, permission, type, PR_TRUE); } if (rememberChecked != permission_GetRememberChecked(type)) { permission_SetRememberChecked(type, rememberChecked); @@ -229,12 +231,14 @@ Permission_Check( } PUBLIC nsresult -Permission_AddHost(const nsAFlatCString & host, PRBool permission, PRInt32 type, PRBool save) { +Permission_AddHost(char * host, PRBool permission, PRInt32 type, PRBool save) { /* create permission list if it does not yet exist */ if(!permission_list) { permission_list = new nsVoidArray(); - if(!permission_list) + if(!permission_list) { + Recycle(host); return NS_ERROR_OUT_OF_MEMORY; + } } /* find existing entry for host */ @@ -245,13 +249,14 @@ Permission_AddHost(const nsAFlatCString & host, PRBool permission, PRInt32 type, for (i = 0; i < hostCount; ++i) { hostStruct = NS_STATIC_CAST(permission_HostStruct*, permission_list->ElementAt(i)); if (hostStruct) { - if (PL_strcasecmp(host.get(),hostStruct->host)==0) { + if (PL_strcasecmp(host,hostStruct->host)==0) { /* host found in list */ + Recycle(host); HostFound = PR_TRUE; break; #ifdef alphabetize - } else if (PL_strcasecmp(host.get(), hostStruct->host) < 0) { + } else if (PL_strcasecmp(host, hostStruct->host) < 0) { /* need to insert new entry here */ break; @@ -264,12 +269,15 @@ Permission_AddHost(const nsAFlatCString & host, PRBool permission, PRInt32 type, /* create a host structure for the host */ hostStruct = PR_NEW(permission_HostStruct); - if (!hostStruct) + if (!hostStruct) { + Recycle(host); return NS_ERROR_FAILURE; - hostStruct->host = ToNewCString(host); + } + hostStruct->host = host; hostStruct->permissionList = new nsVoidArray(); if(!hostStruct->permissionList) { PR_Free(hostStruct); + Recycle(host); return NS_ERROR_FAILURE; } @@ -314,7 +322,7 @@ Permission_AddHost(const nsAFlatCString & host, PRBool permission, PRInt32 type, } PRIVATE void -permission_Unblock(const char * host, PRInt32 type) { +permission_Unblock(char * host, PRInt32 type) { /* nothing to do if permission list does not exist */ if(!permission_list) { @@ -448,7 +456,7 @@ PERMISSION_Read() { if(!permission_list) { return NS_ERROR_OUT_OF_MEMORY; } - nsCAutoString buffer; + nsAutoString buffer; nsFileSpec dirSpec; nsresult rv = CKutil_ProfileDirectory(dirSpec); if (NS_FAILED(rv)) { @@ -469,7 +477,7 @@ PERMISSION_Read() { */ while(CKutil_GetLine(strm,buffer) != -1) { if ( !buffer.IsEmpty() ) { - char firstChar = buffer.CharAt(0); + PRUnichar firstChar = buffer.CharAt(0); if (firstChar == '#' || firstChar == nsCRT::CR || firstChar == nsCRT::LF || firstChar == 0) { continue; @@ -489,9 +497,10 @@ PERMISSION_Read() { hostIndex++; } - nsDependentCSubstring host(buffer, hostIndex, permissionIndex-hostIndex-1); + nsAutoString host; + buffer.Mid(host, hostIndex, permissionIndex-hostIndex-1); - nsCAutoString permissionString; + nsAutoString permissionString; for (;;) { if (nextPermissionIndex == buffer.Length()+1) { break; @@ -499,8 +508,6 @@ PERMISSION_Read() { if ((nextPermissionIndex=buffer.FindChar('\t', permissionIndex)+1) == 0) { nextPermissionIndex = buffer.Length()+1; } - // XXX would like to use nsDependentCSubstring to avoid this allocation, - // but it unfortunately doesn't provide the CharAt method. buffer.Mid(permissionString, permissionIndex, nextPermissionIndex-permissionIndex-1); permissionIndex = nextPermissionIndex; @@ -524,13 +531,13 @@ PERMISSION_Read() { * a host value of "@@@@" is a special code designating the * state of the nag-box's checkmark */ - if (host.Equals(NS_LITERAL_CSTRING("@@@@"))) { + if (host.Equals(NS_LITERAL_STRING("@@@@"))) { if (!permissionString.IsEmpty()) { permission_SetRememberChecked(type, permission); } } else { if (!permissionString.IsEmpty()) { - rv = Permission_AddHost(PromiseFlatCString(host), permission, type, PR_FALSE); + rv = Permission_AddHost(ToNewCString(host), permission, type, PR_FALSE); if (NS_FAILED(rv)) { strm.close(); return rv; @@ -624,7 +631,7 @@ permission_remove (PRInt32 hostNumber, PRInt32 type) { } PUBLIC void -PERMISSION_Remove(const nsACString & host, PRInt32 type) { +PERMISSION_Remove(const char* host, PRInt32 type) { /* get to the indicated host in the list */ if (permission_list) { @@ -635,7 +642,7 @@ PERMISSION_Remove(const nsACString & host, PRInt32 type) { hostStruct = NS_STATIC_CAST(permission_HostStruct*, permission_list->ElementAt(hostCount)); NS_ASSERTION(hostStruct, "corrupt permission list"); - if (host.Equals(hostStruct->host)) { + if ((PL_strcmp(hostStruct->host, host) == 0)) { /* get to the indicated permission in the list */ PRInt32 typeCount = hostStruct->permissionList->Count(); @@ -693,14 +700,17 @@ PERMISSION_DeletePersistentUserData(void) } PUBLIC void -PERMISSION_Add(nsIURI * objectURI, PRBool permission, PRInt32 type) { - if (!objectURI) { +PERMISSION_Add(const char * objectURL, PRBool permission, PRInt32 type, + nsIIOService* ioService) { + if (!objectURL) { return; } - nsCAutoString hostPort; - objectURI->GetHostPort(hostPort); - if (hostPort.IsEmpty()) - return; + nsresult rv = NS_OK; + nsCAutoString host; + NS_ASSERTION(ioService, "IOService not available"); + rv = ioService->ExtractUrlPart(nsDependentCString(objectURL), + nsIIOService::url_Host | + nsIIOService::url_Port, host); /* * if permission is false, it will be added to the permission list @@ -708,32 +718,34 @@ PERMISSION_Add(nsIURI * objectURI, PRBool permission, PRInt32 type) { * true permission being added */ if (permission) { - const char * hostPtr = hostPort.get(); + char * hostPtr = (char *)host.get(); while (PR_TRUE) { permission_Unblock(hostPtr, type); hostPtr = PL_strchr(hostPtr, '.'); if (!hostPtr) { break; } - hostPtr++; /* get past the period */ + hostPtr++; /* get passed the period */ } return; } - Permission_AddHost(hostPort, permission, type, PR_TRUE); + Permission_AddHost(ToNewCString(host), permission, type, PR_TRUE); } PUBLIC void -PERMISSION_TestForBlocking(nsIURI * objectURI, PRBool* blocked, PRInt32 type) { - if (!objectURI) { +PERMISSION_TestForBlocking(const char * objectURL, PRBool* blocked, PRInt32 type, + nsIIOService* ioService) { + if (!objectURL) { return; } nsresult rv = NS_OK; - nsCAutoString hostPort; - objectURI->GetHostPort(hostPort); - if (hostPort.IsEmpty()) - return; + nsCAutoString host; + NS_ASSERTION(ioService, "IOService not available"); + rv = ioService->ExtractUrlPart(nsDependentCString(objectURL), + nsIIOService::url_Host | + nsIIOService::url_Port, host); - const char * hostPtr = hostPort.get(); + const char * hostPtr = host.get(); while (PR_TRUE) { PRBool permission; rv = permission_CheckFromList(hostPtr, permission, type); diff --git a/mozilla/extensions/cookie/nsPermissions.h b/mozilla/extensions/cookie/nsPermissions.h index 9baf5854fb9..68b17a46331 100644 --- a/mozilla/extensions/cookie/nsPermissions.h +++ b/mozilla/extensions/cookie/nsPermissions.h @@ -40,8 +40,7 @@ #define PERMISSIONS_H #include "nsString.h" - -class nsIURI; +#include "nsIIOService.h" #define COOKIEPERMISSION 0 #define IMAGEPERMISSION 1 @@ -57,8 +56,8 @@ typedef enum { class nsIPrompt; extern nsresult PERMISSION_Read(); -extern void PERMISSION_Add(nsIURI * objectURI, PRBool permission, PRInt32 type); -extern void PERMISSION_TestForBlocking(nsIURI * objectURL, PRBool* blocked, PRInt32 type); +extern void PERMISSION_Add(const char * objectURL, PRBool permission, PRInt32 type, nsIIOService* ioService); +extern void PERMISSION_TestForBlocking(const char * objectURL, PRBool* blocked, PRInt32 type, nsIIOService* ioService); extern void PERMISSION_RemoveAll(); extern void PERMISSION_DeletePersistentUserData(void); @@ -66,13 +65,13 @@ extern PRInt32 PERMISSION_HostCount(); extern PRInt32 PERMISSION_TypeCount(PRInt32 host); extern nsresult PERMISSION_Enumerate (PRInt32 hostNumber, PRInt32 typeNumber, char **host, PRInt32 *type, PRBool *capability); -extern void PERMISSION_Remove(const nsACString & host, PRInt32 type); +extern void PERMISSION_Remove(const char* host, PRInt32 type); extern PRBool Permission_Check (nsIPrompt *aPrompter, const char * hostname, PRInt32 type, PRBool warningPref, const char * message_string, int count_for_message); extern nsresult Permission_AddHost - (const nsAFlatCString &host, PRBool permission, PRInt32 type, PRBool save); + (char * host, PRBool permission, PRInt32 type, PRBool save); //extern void Permission_Free(PRInt32 hostNumber, PRInt32 type, PRBool save); extern void Permission_Save(); diff --git a/mozilla/extensions/cookie/nsUtils.cpp b/mozilla/extensions/cookie/nsUtils.cpp index 3f4bb99780c..6eb1d71947a 100644 --- a/mozilla/extensions/cookie/nsUtils.cpp +++ b/mozilla/extensions/cookie/nsUtils.cpp @@ -79,7 +79,7 @@ ckutil_getChar(nsInputFileStream& strm, char& c) { * strip carriage returns and line feeds from end of line */ PUBLIC PRInt32 -CKutil_GetLine(nsInputFileStream& strm, nsACString& aLine) { +CKutil_GetLine(nsInputFileStream& strm, nsString& aLine) { /* read the line */ aLine.Truncate(); @@ -93,7 +93,7 @@ CKutil_GetLine(nsInputFileStream& strm, nsACString& aLine) { } if (c != '\r') { - aLine.Append(c); + aLine.Append(PRUnichar(c)); } } return 0; diff --git a/mozilla/extensions/cookie/nsUtils.h b/mozilla/extensions/cookie/nsUtils.h index 8cc88d475ec..73030ba0ed2 100644 --- a/mozilla/extensions/cookie/nsUtils.h +++ b/mozilla/extensions/cookie/nsUtils.h @@ -42,7 +42,7 @@ #include "nsString.h" #include "nsFileStream.h" -extern PRInt32 CKutil_GetLine(nsInputFileStream& strm, nsACString& aLine); +extern PRInt32 CKutil_GetLine(nsInputFileStream& strm, nsString& aLine); extern PRUnichar* CKutil_Localize(const PRUnichar *genericString); extern nsresult CKutil_ProfileDirectory(nsFileSpec& dirSpec); extern char * CKutil_StrAllocCopy(char *&destination, const char *source); diff --git a/mozilla/extensions/wallet/signonviewer/SignonViewer.js b/mozilla/extensions/wallet/signonviewer/SignonViewer.js index 4dd46cc7ef8..575bc7bf6b1 100644 --- a/mozilla/extensions/wallet/signonviewer/SignonViewer.js +++ b/mozilla/extensions/wallet/signonviewer/SignonViewer.js @@ -184,7 +184,7 @@ function LoadSignons() { .getService(Components.interfaces.nsIIOService); var username; try { - username = ioService.newURI(host, null, null).username; + username = ioService.extractUrlPart(host, ioService.url_Username, unused, unused); } catch(e) { username = ""; } diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index fe90e0ab7fe..770bd9af3c4 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -449,6 +449,10 @@ nsWalletlibService::OnStateChange(nsIWebProgress* aWebProgress, return NS_OK; } + nsCAutoString spec; + rv = uri->GetSpec(spec); + if (NS_FAILED(rv)) return rv; + nsCOMPtr forms; rv = htmldoc->GetForms(getter_AddRefs(forms)); if (NS_FAILED(rv) || (forms == nsnull)) return rv; @@ -525,7 +529,7 @@ nsWalletlibService::OnStateChange(nsIWebProgress* aWebProgress, wwatch->GetNewPrompter(0, getter_AddRefs(prompter)); } if (prompter) { - SINGSIGN_RestoreSignonData(prompter, uri, nameString, &valueString, elementNumber++); + SINGSIGN_RestoreSignonData(prompter, spec.get(), nameString, &valueString, elementNumber++); } if (valueString) { value = valueString; diff --git a/mozilla/extensions/wallet/src/singsign.cpp b/mozilla/extensions/wallet/src/singsign.cpp index 0a076cc376d..931e79f580f 100644 --- a/mozilla/extensions/wallet/src/singsign.cpp +++ b/mozilla/extensions/wallet/src/singsign.cpp @@ -2067,23 +2067,34 @@ si_RememberSignonData PUBLIC void SINGSIGN_RememberSignonData - (nsIPrompt* dialog, nsIURI* passwordRealm, nsVoidArray * signonData, + (nsIPrompt* dialog, const char* passwordRealm, nsVoidArray * signonData, nsIDOMWindowInternal* window) { - if (!passwordRealm) - return; nsCAutoString strippedRealm; + nsCOMPtr ioService = do_GetService(NS_IOSERVICE_CONTRACTID); + if (!ioService) return; /* Hacky security check: If address is of a scheme that - * doesn't support hostnames, we have no host to get the signon data from, - * so we must not attempt to restore the signon data (bug 159484) */ - nsresult rv = passwordRealm->GetHost(strippedRealm); - if (NS_FAILED(rv)) - return; + doesn't support hostnames, we have no host to get the signon data from, + so we must not attempt to restore the signon data (bug 159484) + */ + nsCOMPtr uri; + nsresult result = ioService->NewURI(nsDependentCString(passwordRealm), + nsnull, nsnull, getter_AddRefs(uri)); + if (NS_FAILED(result)) { + return; + } + nsCAutoString tempHost; + result = uri->GetHost(tempHost); + if (NS_FAILED(result)) { + return; + } - if (!strippedRealm.IsEmpty()) + ioService->ExtractUrlPart(nsDependentCString(passwordRealm), nsIIOService::url_Host, strippedRealm); + if (!strippedRealm.IsEmpty()) { si_RememberSignonData(dialog, strippedRealm.get(), signonData, window); + } } PRIVATE void @@ -2191,20 +2202,29 @@ si_RestoreSignonData(nsIPrompt* dialog, const char* passwordRealm, const PRUnich } PUBLIC void -SINGSIGN_RestoreSignonData(nsIPrompt* dialog, nsIURI* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) { - if (!passwordRealm) - return; - +SINGSIGN_RestoreSignonData(nsIPrompt* dialog, const char* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber) { nsCAutoString strippedRealm; + nsCOMPtr ioService = do_GetService(NS_IOSERVICE_CONTRACTID); + if (!ioService) return; /* Hacky security check: If address is of a scheme that - * doesn't support hostnames, we have no host to get the signon data from, - * so we must not attempt to restore the signon data (bug 159484) */ - nsresult rv = passwordRealm->GetHost(strippedRealm); - if (NS_FAILED(rv)) - return; + doesn't support hostnames, we have no host to get the signon data from, + so we must not attempt to restore the signon data (bug 159484) + */ + nsCOMPtr uri; + nsresult result = ioService->NewURI(nsDependentCString(passwordRealm), + nsnull, nsnull, getter_AddRefs(uri)); + if (NS_FAILED(result)) { + return; + } + nsCAutoString tempHost; + result = uri->GetHost(tempHost); + if (NS_FAILED(result)) { + return; + } - si_RestoreSignonData(dialog, strippedRealm.get(), name, value, elementNumber); + ioService->ExtractUrlPart(nsDependentCString(passwordRealm), nsIIOService::url_Host, strippedRealm); + si_RestoreSignonData(dialog, (char*)strippedRealm.get(), name, value, elementNumber); } /* diff --git a/mozilla/extensions/wallet/src/singsign.h b/mozilla/extensions/wallet/src/singsign.h index 16b43b4c3b6..30ae1386f86 100644 --- a/mozilla/extensions/wallet/src/singsign.h +++ b/mozilla/extensions/wallet/src/singsign.h @@ -50,8 +50,6 @@ #include "nsIPref.h" #include "nsIDOMWindowInternal.h" -class nsIURI; - /* Duplicates defines as in nsIPrompt.idl -- keep in sync! */ #define SINGSIGN_SAVE_PASSWORD_NEVER 0 #define SINGSIGN_SAVE_PASSWORD_FOR_SESSION 1 @@ -80,7 +78,7 @@ extern void SINGSIGN_SignonViewerReturn(const nsString& results); extern void -SINGSIGN_RestoreSignonData(nsIPrompt* dialog, nsIURI* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber); +SINGSIGN_RestoreSignonData(nsIPrompt* dialog, const char* passwordRealm, const PRUnichar* name, PRUnichar** value, PRUint32 elementNumber); extern nsresult SINGSIGN_PromptUsernameAndPassword @@ -162,7 +160,7 @@ SINGSIGN_ReencryptAll(); extern void SINGSIGN_RememberSignonData - (nsIPrompt* dialog, nsIURI* uri, nsVoidArray * signonData, nsIDOMWindowInternal* window); + (nsIPrompt* dialog, const char* URLName, nsVoidArray * signonData, nsIDOMWindowInternal* window); PR_END_EXTERN_C diff --git a/mozilla/extensions/wallet/src/wallet.cpp b/mozilla/extensions/wallet/src/wallet.cpp index 6aeda6b75e6..c871791fd49 100644 --- a/mozilla/extensions/wallet/src/wallet.cpp +++ b/mozilla/extensions/wallet/src/wallet.cpp @@ -3912,6 +3912,7 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindowInternal* window) { nsCOMPtr currentFormNode(do_QueryInterface(currentForm)); /* get url name as ascii string */ + nsCAutoString URLName; nsAutoString strippedURLNameUCS2; nsCOMPtr doc; currentForm->GetDocument(*getter_AddRefs(doc)); @@ -3923,6 +3924,7 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindowInternal* window) { if (!docURL || wallet_IsFromCartman(docURL)) { return; } + (void)docURL->GetSpec(URLName); wallet_GetHostFile(docURL, strippedURLNameUCS2); nsCAutoString strippedURLNameUTF8 = NS_ConvertUCS2toUTF8(strippedURLNameUCS2); @@ -4125,7 +4127,7 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindowInternal* window) { wwatch->GetNewPrompter(0, getter_AddRefs(dialog)); if (dialog) { - SINGSIGN_RememberSignonData(dialog, docURL, signonData, window); + SINGSIGN_RememberSignonData(dialog, (char*)URLName.get(), signonData, window); } } PRInt32 count2 = signonData->Count(); diff --git a/mozilla/mailnews/base/src/nsMessengerMigrator.cpp b/mozilla/mailnews/base/src/nsMessengerMigrator.cpp index deedbb4d7ce..b51dd4d82e2 100644 --- a/mozilla/mailnews/base/src/nsMessengerMigrator.cpp +++ b/mozilla/mailnews/base/src/nsMessengerMigrator.cpp @@ -40,7 +40,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsISupportsArray.h" -#include "nsNetUtil.h" +#include "nsIIOService.h" #include "prmem.h" #include "plstr.h" @@ -965,14 +965,13 @@ nsMessengerMigrator::Convert4XUri(const char *old_uri, PRBool for_news, const ch nsXPIDLCString hostname; nsXPIDLCString username; - nsCOMPtr uri; - rv = NS_NewURI(getter_AddRefs(uri), nsDependentCString(old_uri)); + nsCOMPtr ioService = do_GetService(NS_IOSERVICE_CONTRACTID); + if (!ioService) return NS_ERROR_FAILURE; + + rv = ioService->ExtractUrlPart(nsDependentCString(old_uri), nsIIOService::url_Host, hostname); if (NS_FAILED(rv)) return rv; - rv = uri->GetHost(hostname); - if (NS_FAILED(rv)) return rv; - - rv = uri->GetUsername(username); + rv = ioService->ExtractUrlPart(nsDependentCString(old_uri), nsIIOService::url_Username, username); if (NS_FAILED(rv)) return rv; // in 4.x, mac and windows stored the URI as IMAP:// diff --git a/mozilla/mailnews/compose/src/nsMsgAttachment.cpp b/mozilla/mailnews/compose/src/nsMsgAttachment.cpp index 8e6488b1edf..3d5428666e7 100644 --- a/mozilla/mailnews/compose/src/nsMsgAttachment.cpp +++ b/mozilla/mailnews/compose/src/nsMsgAttachment.cpp @@ -178,10 +178,10 @@ nsresult nsMsgAttachment::DeleteAttachment() nsresult rv; PRBool isAFile = PR_FALSE; - nsCOMPtr urlFile; + nsCOMPtr urlFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) { - rv = NS_GetFileFromURLSpec(mUrl, getter_AddRefs(urlFile)); + NS_InitFileFromURLSpec(urlFile, mUrl); if (NS_SUCCEEDED(rv)) { PRBool bExists = PR_FALSE; diff --git a/mozilla/modules/libjar/nsJARURI.cpp b/mozilla/modules/libjar/nsJARURI.cpp index 9d57b3512ab..aeacfe46c7e 100644 --- a/mozilla/modules/libjar/nsJARURI.cpp +++ b/mozilla/modules/libjar/nsJARURI.cpp @@ -25,7 +25,6 @@ #include "nsIServiceManager.h" #include "nsIZipReader.h" #include "nsReadableUtils.h" -#include "nsURLHelper.h" //////////////////////////////////////////////////////////////////////////////// @@ -92,11 +91,11 @@ NS_IMETHODIMP nsJARURI::SetSpec(const nsACString &aSpec) { nsresult rv; - nsCOMPtr ioServ(do_GetIOService(&rv)); + nsCOMPtr serv(do_GetIOService(&rv)); if (NS_FAILED(rv)) return rv; nsCAutoString scheme; - rv = ::ExtractURLScheme(aSpec, nsnull, nsnull, &scheme); + rv = serv->ExtractScheme(aSpec, scheme); if (NS_FAILED(rv)) return rv; if (strcmp("jar", scheme.get()) != 0) @@ -120,16 +119,16 @@ nsJARURI::SetSpec(const nsACString &aSpec) begin.advance(4); - rv = ioServ->NewURI(Substring(begin, delim_begin), mCharsetHint.get(), nsnull, getter_AddRefs(mJARFile)); + rv = serv->NewURI(Substring(begin, delim_begin), mCharsetHint.get(), nsnull, getter_AddRefs(mJARFile)); if (NS_FAILED(rv)) return rv; // skip over any extra '/' chars while (*delim_end == '/') ++delim_end; - rv = ::ResolveRelativePath(Substring(delim_end, end), - NS_LITERAL_CSTRING(""), - mJAREntry); + rv = serv->ResolveRelativePath(Substring(delim_end, end), + NS_LITERAL_CSTRING(""), + mJAREntry); return rv; } @@ -328,8 +327,11 @@ nsJARURI::Resolve(const nsACString &relativePath, nsACString &result) { nsresult rv; + nsCOMPtr serv(do_GetIOService(&rv)); + if (NS_FAILED(rv)) return rv; + nsCAutoString scheme; - rv = ::ExtractURLScheme(relativePath, nsnull, nsnull, &scheme); + rv = serv->ExtractScheme(relativePath, scheme); if (NS_SUCCEEDED(rv)) { // then aSpec is absolute result = relativePath; @@ -344,8 +346,8 @@ nsJARURI::Resolve(const nsACString &relativePath, nsACString &result) path = ""; nsCAutoString resolvedEntry; - rv = ::ResolveRelativePath(relativePath, path, - resolvedEntry); + rv = serv->ResolveRelativePath(relativePath, path, + resolvedEntry); if (NS_FAILED(rv)) return rv; return FormatSpec(resolvedEntry, result); @@ -383,11 +385,13 @@ nsJARURI::GetJAREntry(nsACString &entryPath) NS_IMETHODIMP nsJARURI::SetJAREntry(const nsACString &entryPath) { + nsresult rv; + nsCOMPtr serv(do_GetIOService(&rv)); + if (NS_FAILED(rv)) return rv; + mJAREntry.Truncate(); - return ::ResolveRelativePath(entryPath, - NS_LITERAL_CSTRING(""), - mJAREntry); + return serv->ResolveRelativePath(entryPath, NS_LITERAL_CSTRING(""), mJAREntry); } //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index e70d357face..76ff33af994 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -6542,23 +6542,15 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa nsresult rv; PRInt64 fileSize; nsCAutoString filename; - // stat file == get size & convert file:///c:/ to c: if needed - nsCOMPtr inFile; - rv = NS_GetFileFromURLSpec(nsDependentCString(postDataURL), - getter_AddRefs(inFile)); - if (NS_FAILED(rv)) { - nsCOMPtr localFile; - rv = NS_NewNativeLocalFile(nsDependentCString(postDataURL), PR_FALSE, - getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; - inFile = localFile; - } - rv = inFile->GetFileSize(&fileSize); - if (NS_FAILED(rv)) return rv; - rv = inFile->GetNativePath(filename); - if (NS_FAILED(rv)) return rv; - + nsCOMPtr inFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv); + if (NS_FAILED(rv) || + (NS_FAILED(rv = NS_InitFileFromURLSpec(inFile, nsDependentCString(postDataURL))) && + NS_FAILED(rv = inFile->InitWithNativePath(nsDependentCString(postDataURL)))) || + NS_FAILED(rv = inFile->GetFileSize(&fileSize)) || + NS_FAILED(rv = inFile->GetNativePath(filename)) + ) + return rv; if (!LL_IS_ZERO(fileSize)) { nsCOMPtr inStream; rv = NS_NewLocalFileInputStream(getter_AddRefs(inStream), inFile); diff --git a/mozilla/netwerk/base/public/nsIIOService.idl b/mozilla/netwerk/base/public/nsIIOService.idl index d8e4355c3bb..0e11c401a9e 100644 --- a/mozilla/netwerk/base/public/nsIIOService.idl +++ b/mozilla/netwerk/base/public/nsIIOService.idl @@ -40,48 +40,33 @@ interface nsIProtocolHandler; interface nsIChannel; interface nsIURI; +interface nsIURLParser; interface nsIFile; -/** - * nsIIOService provides a set of utility functions for necko. The interface - * duplicates many of the nsIProtocolHandler methods in a protocol handler - * independent way (e.g., NewURI sniffs the scheme to determine which protocol - * handler's NewURI should be invoked). nsIIOService also provides a set of - * URL parsing utility functions. These are provided to make the programmers - * job easier and in some cases to improve performance by eliminating - * intermediate data structures and interfaces. - * - * @status UNDER_REVIEW - */ [scriptable, uuid(ab7c3a84-d488-11d3-8cda-0060b0fc14a3)] interface nsIIOService : nsISupports { - /************************************************************************* - * Protocol handler utilities - */ - /** * Returns a protocol handler for a given URI scheme. * - * @param aScheme the URI scheme - * @return reference to corresponding nsIProtocolHandler + * @param scheme URI scheme + * @return reference to nsIProtcolHandler */ - nsIProtocolHandler getProtocolHandler(in string aScheme); + nsIProtocolHandler getProtocolHandler(in string scheme); /** * Returns the protocol flags for a given scheme. * - * @param aScheme the URI scheme - * @return value of corresponding nsIProtocolHandler::protocolFlags + * @param scheme URI scheme + * @return returns unsigned long for protocol flags */ - unsigned long getProtocolFlags(in string aScheme); + unsigned long getProtocolFlags(in string scheme); /** * This method constructs a new URI by first determining the scheme * of the URI spec, and then delegating the construction of the URI * to the protocol handler for that scheme. QueryInterface can be used * on the resulting URI object to obtain a more specific type of URI. - * * @see nsIProtocolHandler::newURI */ nsIURI newURI(in AUTF8String aSpec, @@ -89,23 +74,32 @@ interface nsIIOService : nsISupports in nsIURI aBaseURI); /** - * This method constructs a new URI from a nsIFile. + * This method constructs a new file URI * - * @param aFile specifies the file path + * @param aFile nsIFile from which to make an URI from * @return reference to a new nsIURI object */ nsIURI newFileURI(in nsIFile aFile); /** - * Creates a channel for a given URI. + * Creates a channel for a given URI. The notificationCallbacks argument + * is used to obtain the appropriate callbacks for the URI's protocol + * from the application. * - * @param aURI nsIURI from which to make a channel - * @return reference to the new nsIChannel object + * @param originalURI - Specifies the original URI which caused the + * creation of this channel. This can occur when the construction of + * one channel (e.g. for resource:) causes another channel to be created + * on its behalf (e.g. a file: channel), or if a redirect occurs, + * causing the current URL to become different from the original URL. + * If NULL, the aURI parameter will be used as the originalURI instead. + * + * @param aURI nsIURI to make a channel from + * @return a reference to the new nsIChannel object */ nsIChannel newChannelFromURI(in nsIURI aURI); /** - * Equivalent to newChannelFromURI(newURI(...)) + * Shortcut equivalent to newChannelFromURI(newURI(...)) */ nsIChannel newChannel(in AUTF8String aSpec, in string aOriginCharset, @@ -121,56 +115,91 @@ interface nsIIOService : nsISupports attribute boolean offline; /** - * Checks if a port number is banned. This involves consulting a black- - * list of port numbers corresponding to services that may be easily - * exploitable. If the given port is found on the black-list, then the - * protocol handler (corresponding to aScheme) will be asked if it wishes - * to override the IO service's decision to block the port. This gives - * the protocol handler ultimate control over its own security policy - * while ensuring reasonable, default protection. + * Checks if a port number is banned. * - * @see nsIProtocolHandler::allowPort + * |allowPort| will check a list of "known-to-do-bad-things" + * port numbers. If the given port is found on the blacklist, + * |allowPort| will ask the protocol handler if it wishes to override. + * Scheme can be null. */ - boolean allowPort(in long aPort, in string aScheme); + boolean allowPort(in long port, in string scheme); - - /************************************************************************* - * URL parsing utilities - * - * The set of methods provided here is intentionally limited. Most of - * Necko's URL parsing functionality is provided via nsIURI. This is - * done to ensure a common point of access to URL parsing, which is - * protocol dependent. Do not try to parse a random URL string as the - * result will likely differ (perhaps only in some subtle way) from the - * value of the corresponding nsIURI attribute. Violating this rule - * may make your code vulnerable to various kinds of security exploits. - * DON'T RISK IT! --darin - */ + //////////////////////////////////////////////////////////////////////////// + // URL parsing utilities /** - * Utility to extract the scheme from a URL string, consistently and - * according to spec (see RFC 2396). + * Utility for protocol implementors -- extracts the scheme from a URL + * string, consistently and according to spec. * - * @param aSpec the URL string to parse - * @return URL scheme + * @param urlString the URL string to parse + * @return scheme * - * @throws NS_ERROR_MALFORMED_URI if URL string is not of the right form. + * @throws NS_ERROR_MALFORMED_URI if urlString is not of the right form. */ ACString extractScheme(in AUTF8String urlString); /** - * Converts the nsIFile to the corresponding URL string. NOTE: under - * some platforms this is a lossy conversion (e.g., Mac Carbon build). - * If the nsIFile is a local file, then the result will be a file:// - * URL string. + * returns the protocol specific URL parser + */ + nsIURLParser getParserForScheme(in string scheme); + + /** + * @param urlString absolute URL path. + * @param flags combination of url_XXX flags. * - * The resulting string may contain URL-escaped characters. + * @throws NS_ERROR_MALFORMED_URI if urlString is not of the right form. + */ + AUTF8String extractUrlPart(in AUTF8String urlString, in short flags); + + /** + * Constants for the mask in the call to extractUrlPart + * + * XXX these should really be enumerated in left-to-right order! + */ + const short url_Scheme = (1<<0); + const short url_Username = (1<<1); + const short url_Password = (1<<2); + const short url_Host = (1<<3); + const short url_Directory = (1<<4); + const short url_FileBaseName = (1<<5); + const short url_FileExtension = (1<<6); + const short url_Param = (1<<7); + const short url_Query = (1<<8); + const short url_Ref = (1<<9); + const short url_Path = (1<<10); + const short url_Port = (1<<11); + + /** + * Resolves a relative path string containing "." and ".." + * with respect to a base path (assumed to already be resolved). + * For example, resolving "../../foo/./bar/../baz.html" w.r.t. + * "/a/b/c/d/e/" yields "/a/b/c/foo/baz.html". Attempting to + * ascend above the base results in the NS_ERROR_MALFORMED_URI + * exception. If basePath is null, it treats it as "/". + * + * @param relativePath a relative URI + * @param basePath a base URI + * + * @return a new string, representing canonical uri + */ + AUTF8String resolveRelativePath(in AUTF8String relativePath, + in AUTF8String basePath); + + /** + * conversions between nsILocalFile and a file url string + */ + + /** + * gets a file:// url out of an nsIFile + * @param file the file to extract the path from + * @return a file:// style url string */ AUTF8String getURLSpecFromFile(in nsIFile file); /** - * Converts the URL string into the corresponding nsIFile if possible. - * A local file will be created if the URL string begins with file://. + * Sets the native path of the file given the url string + * @param file the file to initialize with the given spec + * @param url the url string which will be used to initialize the file */ - nsIFile getFileFromURLSpec(in AUTF8String url); + void initFileFromURLSpec(in nsIFile file, in AUTF8String url); }; diff --git a/mozilla/netwerk/base/public/nsNetUtil.h b/mozilla/netwerk/base/public/nsNetUtil.h index 76b7bae4fdc..d8dd661f954 100644 --- a/mozilla/netwerk/base/public/nsNetUtil.h +++ b/mozilla/netwerk/base/public/nsNetUtil.h @@ -739,8 +739,8 @@ NS_NewProxyInfo(const char* type, const char* host, PRInt32 port, nsIProxyInfo* } inline nsresult -NS_GetFileFromURLSpec(const nsACString &inURL, nsIFile **result, - nsIIOService *ioService=nsnull) +NS_InitFileFromURLSpec(nsIFile* aFile, const nsACString &inURL, + nsIIOService *ioService=nsnull) { nsCOMPtr serv; if (ioService == nsnull) { @@ -749,7 +749,7 @@ NS_GetFileFromURLSpec(const nsACString &inURL, nsIFile **result, if (NS_FAILED(rv)) return rv; ioService = serv.get(); } - return ioService->GetFileFromURLSpec(inURL, result); + return ioService->InitFileFromURLSpec(aFile, inURL); } inline nsresult diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index 3d4944950ab..73ee8528d11 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -479,7 +479,8 @@ nsIOService::ExtractScheme(const nsACString &inURI, nsACString &scheme) return ExtractURLScheme(inURI, nsnull, nsnull, &scheme); } -NS_METHOD +/* nsIURLParser getParserForScheme (in string scheme); */ +NS_IMETHODIMP nsIOService::GetParserForScheme(const char *scheme, nsIURLParser **_retval) { nsresult rv; @@ -548,7 +549,6 @@ nsIOService::GetParserForScheme(const char *scheme, nsIURLParser **_retval) return NS_OK; } -#if 0 static inline void ExtractUrlPart_Helper(const nsACString &src, PRUint32 pos, PRInt32 len, nsACString &result) { @@ -706,7 +706,6 @@ nsIOService::ExtractUrlPart(const nsACString &urlString, PRInt16 flag, nsACStrin } return NS_OK; } -#endif NS_IMETHODIMP nsIOService::GetProtocolFlags(const char* scheme, PRUint32 *flags) @@ -905,6 +904,77 @@ nsIOService::AllowPort(PRInt32 inPort, const char *scheme, PRBool *_retval) *_retval = PR_TRUE; return NS_OK; } +//////////////////////////////////////////////////////////////////////////////// +// URL parsing utilities + +NS_IMETHODIMP +nsIOService::ResolveRelativePath(const nsACString &relativePath, const nsACString &basePath, + nsACString &result) +{ + nsCAutoString name; + nsCAutoString path(basePath); + PRBool needsDelim = PR_FALSE; + + if ( !path.IsEmpty() ) { + PRUnichar last = path.Last(); + needsDelim = !(last == '/' || last == '\\' ); + } + + nsACString::const_iterator beg, end; + relativePath.BeginReading(beg); + relativePath.EndReading(end); + + PRBool stop = PR_FALSE; + char c; + for (; !stop; ++beg) { + c = (beg == end) ? '\0' : *beg; + //printf("%c [name=%s] [path=%s]\n", c, name.get(), path.get()); + switch (c) { + case '\0': + case '#': + case ';': + case '?': + stop = PR_TRUE; + // fall through... + case '/': + case '\\': + // delimiter found + if (name.Equals("..")) { + // pop path + // If we already have the delim at end, then + // skip over that when searching for next one to the left + PRInt32 offset = path.Length() - (needsDelim ? 1 : 2); + PRInt32 pos = path.RFind("/", PR_FALSE, offset); + if (pos > 0) + path.Truncate(pos + 1); + else + return NS_ERROR_MALFORMED_URI; + } + else if (name.Equals(".") || name.Equals("")) { + // do nothing + } + else { + // append name to path + if (needsDelim) + path += "/"; + path += name; + needsDelim = PR_TRUE; + } + name = ""; + break; + + default: + // append char to name + name += c; + } + } + // append anything left on relativePath (e.g. #..., ;..., ?...) + if (c != '\0') + path += Substring(--beg, end); + + result = path; + return NS_OK; +} //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/base/src/nsIOService.h b/mozilla/netwerk/base/src/nsIOService.h index 3259d13d30c..ca4c6fa1fbb 100644 --- a/mozilla/netwerk/base/src/nsIOService.h +++ b/mozilla/netwerk/base/src/nsIOService.h @@ -100,8 +100,6 @@ protected: NS_METHOD CacheURLParser(const char *scheme, nsIURLParser* hdlr); - NS_METHOD GetParserForScheme(const char *scheme, nsIURLParser **); - // Prefs wrangling void PrefsChanged(nsIPrefBranch *prefs, const char *pref = nsnull); void GetPrefBranch(nsIPrefBranch **); diff --git a/mozilla/netwerk/base/src/nsIOServiceMac.cpp b/mozilla/netwerk/base/src/nsIOServiceMac.cpp index 89579605074..f8b85e0ba0a 100644 --- a/mozilla/netwerk/base/src/nsIOServiceMac.cpp +++ b/mozilla/netwerk/base/src/nsIOServiceMac.cpp @@ -110,13 +110,12 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &aURL) } NS_IMETHODIMP -nsIOService::GetFileFromURLSpec(const nsACString &aURL, nsIFile **result) +nsIOService::InitFileFromURLSpec(nsIFile *aFile, const nsACString &aURL) { nsresult rv; NS_ENSURE_ARG(result); - nsCOMPtr localFile( - do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); + nsCOMPtr localFile = do_QueryInterface(aFile, &rv); if (NS_FAILED(rv)) { NS_ERROR("Only nsILocalFile supported right now"); return rv; @@ -153,9 +152,5 @@ nsIOService::GetFileFromURLSpec(const nsACString &aURL, nsIFile **result) path.Cut(0, 1); // assuming path is encoded in the native charset - rv = localFile->InitWithNativePath(path); - if (NS_FAILED(rv)) return rv; - - NS_ADDREF(*result = localFile); - return NS_OK; + return localFile->InitWithNativePath(path); } diff --git a/mozilla/netwerk/base/src/nsIOServiceOS2.cpp b/mozilla/netwerk/base/src/nsIOServiceOS2.cpp index 55f3f6ec386..c0b57e3b6bb 100644 --- a/mozilla/netwerk/base/src/nsIOServiceOS2.cpp +++ b/mozilla/netwerk/base/src/nsIOServiceOS2.cpp @@ -96,12 +96,11 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result) } NS_IMETHODIMP -nsIOService::GetFileFromURLSpec(const nsACString &aURL, nsIFile **result) +nsIOService::InitFileFromURLSpec(nsIFile *aFile, const nsACString &aURL) { nsresult rv; - nsCOMPtr localFile( - do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); + nsCOMPtr localFile = do_QueryInterface(aFile, &rv); if (NS_FAILED(rv)) { NS_ERROR("Only nsILocalFile supported right now"); return rv; @@ -134,11 +133,7 @@ nsIOService::GetFileFromURLSpec(const nsACString &aURL, nsIFile **result) path.Cut(0, 1); // assuming path is encoded in the native charset - rv = localFile->InitWithNativePath(path); - if (NS_FAILED(rv)) return rv; - - NS_ADDREF(*result = localFile); - return NS_OK; + return localFile->InitWithNativePath(path); } static int isleadbyte(int c) diff --git a/mozilla/netwerk/base/src/nsIOServiceUnix.cpp b/mozilla/netwerk/base/src/nsIOServiceUnix.cpp index b1d15e3eac4..96d00a1b6eb 100644 --- a/mozilla/netwerk/base/src/nsIOServiceUnix.cpp +++ b/mozilla/netwerk/base/src/nsIOServiceUnix.cpp @@ -80,12 +80,11 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result) } NS_IMETHODIMP -nsIOService::GetFileFromURLSpec(const nsACString &aURL, nsIFile **result) +nsIOService::InitFileFromURLSpec(nsIFile* aFile, const nsACString &aURL) { nsresult rv; - nsCOMPtr localFile( - do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); + nsCOMPtr localFile = do_QueryInterface(aFile, &rv); if (NS_FAILED(rv)) { NS_ERROR("Only nsILocalFile supported right now"); return rv; @@ -108,9 +107,5 @@ nsIOService::GetFileFromURLSpec(const nsACString &aURL, nsIFile **result) NS_UnescapeURL(path); // assuming path is encoded in the native charset - rv = localFile->InitWithNativePath(path); - if (NS_FAILED(rv)) return rv; - - NS_ADDREF(*result = localFile); - return NS_OK; + return localFile->InitWithNativePath(path); } diff --git a/mozilla/netwerk/base/src/nsIOServiceWin.cpp b/mozilla/netwerk/base/src/nsIOServiceWin.cpp index 182f19613b7..7f1e3eda4e0 100644 --- a/mozilla/netwerk/base/src/nsIOServiceWin.cpp +++ b/mozilla/netwerk/base/src/nsIOServiceWin.cpp @@ -93,12 +93,11 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result) } NS_IMETHODIMP -nsIOService::GetFileFromURLSpec(const nsACString &aURL, nsIFile **result) +nsIOService::InitFileFromURLSpec(nsIFile *aFile, const nsACString &aURL) { nsresult rv; - nsCOMPtr localFile( - do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); + nsCOMPtr localFile = do_QueryInterface(aFile, &rv); if (NS_FAILED(rv)) { NS_ERROR("Only nsILocalFile supported right now"); return rv; @@ -131,9 +130,5 @@ nsIOService::GetFileFromURLSpec(const nsACString &aURL, nsIFile **result) path.Cut(0, 1); // assuming path is encoded in the native charset - rv = localFile->InitWithNativePath(path); - if (NS_FAILED(rv)) return rv; - - NS_ADDREF(*result = localFile); - return NS_OK; + return localFile->InitWithNativePath(path); } diff --git a/mozilla/netwerk/base/src/nsStandardURL.cpp b/mozilla/netwerk/base/src/nsStandardURL.cpp index 216d421d0f1..d329dac6ede 100644 --- a/mozilla/netwerk/base/src/nsStandardURL.cpp +++ b/mozilla/netwerk/base/src/nsStandardURL.cpp @@ -57,7 +57,6 @@ static NS_DEFINE_CID(kThisImplCID, NS_THIS_STANDARDURL_IMPL_CID); static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); -nsIIOService *nsStandardURL::gIOService = nsnull; nsIURLParser *nsStandardURL::gNoAuthParser = nsnull; nsIURLParser *nsStandardURL::gAuthParser = nsnull; nsIURLParser *nsStandardURL::gStdParser = nsnull; @@ -365,13 +364,6 @@ nsStandardURL::InitGlobalObjects() NS_ADDREF(gStdParser); } - nsCOMPtr serv(do_GetIOService()); - NS_ASSERTION(serv, "failed getting IO service"); - if (serv) { - gIOService = serv.get(); - NS_ADDREF(gIOService); - } - nsCOMPtr prefService( do_GetService(NS_PREFSERVICE_CONTRACTID) ); if (prefService) { nsCOMPtr prefBranch; @@ -390,7 +382,6 @@ nsStandardURL::InitGlobalObjects() void nsStandardURL::ShutdownGlobalObjects() { - NS_IF_RELEASE(gIOService); NS_IF_RELEASE(gNoAuthParser); NS_IF_RELEASE(gAuthParser); NS_IF_RELEASE(gStdParser); @@ -2178,20 +2169,23 @@ nsStandardURL::GetFile(nsIFile **result) return NS_ERROR_FAILURE; } - nsresult rv = gIOService->GetFileFromURLSpec(mSpec, getter_AddRefs(mFile)); + nsresult rv; + nsCOMPtr localFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv)); + if (NS_FAILED(rv)) return rv; + + rv = NS_InitFileFromURLSpec(localFile, mSpec); if (NS_FAILED(rv)) return rv; #if defined(PR_LOGGING) if (LOG_ENABLED()) { nsCAutoString path; - mFile->GetNativePath(path); + localFile->GetNativePath(path); LOG(("nsStandardURL::GetFile [this=%p spec=%s resulting_path=%s]\n", this, mSpec.get(), path.get())); } #endif - NS_ADDREF(*result = mFile); - return NS_OK; + return CallQueryInterface(localFile, result); } NS_IMETHODIMP @@ -2204,7 +2198,7 @@ nsStandardURL::SetFile(nsIFile *file) nsresult rv; nsCAutoString url; - rv = gIOService->GetURLSpecFromFile(file, url); + rv = NS_GetURLSpecFromFile(file, url); if (NS_FAILED(rv)) return rv; rv = SetSpec(url); diff --git a/mozilla/netwerk/base/src/nsStandardURL.h b/mozilla/netwerk/base/src/nsStandardURL.h index 585208ce1f4..4c162da282c 100644 --- a/mozilla/netwerk/base/src/nsStandardURL.h +++ b/mozilla/netwerk/base/src/nsStandardURL.h @@ -49,7 +49,6 @@ #include "nsIURLParser.h" #include "nsIUnicodeEncoder.h" #include "nsIObserver.h" -#include "nsIIOService.h" #include "nsCOMPtr.h" class nsIBinaryInputStream; @@ -240,7 +239,6 @@ private: // global objects. don't use COMPtr as its destructor will cause a // coredump if we leak it. - static nsIIOService *gIOService; static nsIURLParser *gNoAuthParser; static nsIURLParser *gAuthParser; static nsIURLParser *gStdParser; diff --git a/mozilla/netwerk/base/src/nsURLHelper.cpp b/mozilla/netwerk/base/src/nsURLHelper.cpp index 93fb38a622f..9cc9ff3344a 100644 --- a/mozilla/netwerk/base/src/nsURLHelper.cpp +++ b/mozilla/netwerk/base/src/nsURLHelper.cpp @@ -355,73 +355,3 @@ IsValidScheme(const char *scheme, PRUint32 schemeLen) return PR_TRUE; } - -nsresult -ResolveRelativePath(const nsACString &relativePath, - const nsACString &basePath, - nsACString &result) -{ - nsCAutoString name; - nsCAutoString path(basePath); - PRBool needsDelim = PR_FALSE; - - if ( !path.IsEmpty() ) { - PRUnichar last = path.Last(); - needsDelim = !(last == '/' || last == '\\' ); - } - - nsACString::const_iterator beg, end; - relativePath.BeginReading(beg); - relativePath.EndReading(end); - - PRBool stop = PR_FALSE; - char c; - for (; !stop; ++beg) { - c = (beg == end) ? '\0' : *beg; - //printf("%c [name=%s] [path=%s]\n", c, name.get(), path.get()); - switch (c) { - case '\0': - case '#': - case ';': - case '?': - stop = PR_TRUE; - // fall through... - case '/': - case '\\': - // delimiter found - if (name.Equals("..")) { - // pop path - // If we already have the delim at end, then - // skip over that when searching for next one to the left - PRInt32 offset = path.Length() - (needsDelim ? 1 : 2); - PRInt32 pos = path.RFind("/", PR_FALSE, offset); - if (pos > 0) - path.Truncate(pos + 1); - else - return NS_ERROR_MALFORMED_URI; - } - else if (name.Equals(".") || name.Equals("")) { - // do nothing - } - else { - // append name to path - if (needsDelim) - path += "/"; - path += name; - needsDelim = PR_TRUE; - } - name = ""; - break; - - default: - // append char to name - name += c; - } - } - // append anything left on relativePath (e.g. #..., ;..., ?...) - if (c != '\0') - path += Substring(--beg, end); - - result = path; - return NS_OK; -} diff --git a/mozilla/netwerk/base/src/nsURLHelper.h b/mozilla/netwerk/base/src/nsURLHelper.h index b763f1c349b..41f6bc1524e 100644 --- a/mozilla/netwerk/base/src/nsURLHelper.h +++ b/mozilla/netwerk/base/src/nsURLHelper.h @@ -74,21 +74,4 @@ inline PRBool IsValidScheme(const nsAFlatCString &scheme) return IsValidScheme(scheme.get(), scheme.Length()); } -/** - * Resolves a relative path string containing "." and ".." - * with respect to a base path (assumed to already be resolved). - * For example, resolving "../../foo/./bar/../baz.html" w.r.t. - * "/a/b/c/d/e/" yields "/a/b/c/foo/baz.html". Attempting to - * ascend above the base results in the NS_ERROR_MALFORMED_URI - * exception. If basePath is null, it treats it as "/". - * - * @param relativePath a relative URI - * @param basePath a base URI - * - * @return a new string, representing canonical uri - */ -nsresult ResolveRelativePath(const nsACString &relativePath, - const nsACString &basePath, - nsACString &result); - #endif diff --git a/mozilla/netwerk/build/nsNetCID.h b/mozilla/netwerk/build/nsNetCID.h index 6899933cf74..2a60f538da7 100644 --- a/mozilla/netwerk/build/nsNetCID.h +++ b/mozilla/netwerk/build/nsNetCID.h @@ -57,19 +57,6 @@ {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \ } -// service implementing nsIURLParsingUtils. -#define NS_URLPARSINGUTILS_CLASSNAME \ - "nsURLParsingUtils" -#define NS_URLPARSINGUTILS_CONTRACTID \ - "@mozilla.org/network/url-parsing-utils;1" -#define NS_URLPARSINGUTILS_CID \ -{ /* bb567799-182e-443f-8c01-d1f97ceb51c8 */ \ - 0xbb567799, \ - 0x182e, \ - 0x443f, \ - {0x8c, 0x01, 0xd1, 0xf9, 0x7c, 0xeb, 0x51, 0xc8} \ -} - // component implementing nsILoadGroup. #define NS_LOADGROUP_CLASSNAME \ "nsLoadGroup" diff --git a/mozilla/netwerk/build/nsNetModule.cpp b/mozilla/netwerk/build/nsNetModule.cpp index 6252f493a49..19649f14848 100644 --- a/mozilla/netwerk/build/nsNetModule.cpp +++ b/mozilla/netwerk/build/nsNetModule.cpp @@ -598,10 +598,6 @@ static const nsModuleComponentInfo gNetModuleInfo[] = { NS_IOSERVICE_CID, NS_IOSERVICE_CONTRACTID, nsIOService::Create }, - { NS_URLPARSINGUTILS_CLASSNAME, - NS_URLPARSINGUTILS_CID, - NS_URLPARSINGUTILS_CONTRACTID, - nsIOService::Create }, // yes, same class implements both services { "File Transport Service", NS_FILETRANSPORTSERVICE_CID, "@mozilla.org/network/file-transport-service;1", diff --git a/mozilla/netwerk/protocol/jar/src/Makefile.in b/mozilla/netwerk/protocol/jar/src/Makefile.in index 5748574a837..fe7d5b6340b 100644 --- a/mozilla/netwerk/protocol/jar/src/Makefile.in +++ b/mozilla/netwerk/protocol/jar/src/Makefile.in @@ -45,9 +45,6 @@ CPPSRCS = \ nsJARURI.cpp \ $(NULL) -LOCAL_INCLUDES = \ - -I$(srcdir)/../../../base/src - # we don't want the shared lib, but we want to force the creation of a # static lib. FORCE_STATIC_LIB = 1 diff --git a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp index 9d57b3512ab..aeacfe46c7e 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp @@ -25,7 +25,6 @@ #include "nsIServiceManager.h" #include "nsIZipReader.h" #include "nsReadableUtils.h" -#include "nsURLHelper.h" //////////////////////////////////////////////////////////////////////////////// @@ -92,11 +91,11 @@ NS_IMETHODIMP nsJARURI::SetSpec(const nsACString &aSpec) { nsresult rv; - nsCOMPtr ioServ(do_GetIOService(&rv)); + nsCOMPtr serv(do_GetIOService(&rv)); if (NS_FAILED(rv)) return rv; nsCAutoString scheme; - rv = ::ExtractURLScheme(aSpec, nsnull, nsnull, &scheme); + rv = serv->ExtractScheme(aSpec, scheme); if (NS_FAILED(rv)) return rv; if (strcmp("jar", scheme.get()) != 0) @@ -120,16 +119,16 @@ nsJARURI::SetSpec(const nsACString &aSpec) begin.advance(4); - rv = ioServ->NewURI(Substring(begin, delim_begin), mCharsetHint.get(), nsnull, getter_AddRefs(mJARFile)); + rv = serv->NewURI(Substring(begin, delim_begin), mCharsetHint.get(), nsnull, getter_AddRefs(mJARFile)); if (NS_FAILED(rv)) return rv; // skip over any extra '/' chars while (*delim_end == '/') ++delim_end; - rv = ::ResolveRelativePath(Substring(delim_end, end), - NS_LITERAL_CSTRING(""), - mJAREntry); + rv = serv->ResolveRelativePath(Substring(delim_end, end), + NS_LITERAL_CSTRING(""), + mJAREntry); return rv; } @@ -328,8 +327,11 @@ nsJARURI::Resolve(const nsACString &relativePath, nsACString &result) { nsresult rv; + nsCOMPtr serv(do_GetIOService(&rv)); + if (NS_FAILED(rv)) return rv; + nsCAutoString scheme; - rv = ::ExtractURLScheme(relativePath, nsnull, nsnull, &scheme); + rv = serv->ExtractScheme(relativePath, scheme); if (NS_SUCCEEDED(rv)) { // then aSpec is absolute result = relativePath; @@ -344,8 +346,8 @@ nsJARURI::Resolve(const nsACString &relativePath, nsACString &result) path = ""; nsCAutoString resolvedEntry; - rv = ::ResolveRelativePath(relativePath, path, - resolvedEntry); + rv = serv->ResolveRelativePath(relativePath, path, + resolvedEntry); if (NS_FAILED(rv)) return rv; return FormatSpec(resolvedEntry, result); @@ -383,11 +385,13 @@ nsJARURI::GetJAREntry(nsACString &entryPath) NS_IMETHODIMP nsJARURI::SetJAREntry(const nsACString &entryPath) { + nsresult rv; + nsCOMPtr serv(do_GetIOService(&rv)); + if (NS_FAILED(rv)) return rv; + mJAREntry.Truncate(); - return ::ResolveRelativePath(entryPath, - NS_LITERAL_CSTRING(""), - mJAREntry); + return serv->ResolveRelativePath(entryPath, NS_LITERAL_CSTRING(""), mJAREntry); } //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp b/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp index 70ebb32935f..aafbb98c64a 100644 --- a/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp +++ b/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.cpp @@ -91,7 +91,14 @@ nsResURL::GetFile(nsIFile **result) rv = gResHandler->ResolveURI(this, spec); if (NS_FAILED(rv)) return rv; - return NS_GetFileFromURLSpec(spec, result, gResHandler->mIOService); + nsCOMPtr localFile = + do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = NS_InitFileFromURLSpec(localFile, spec); + if (NS_FAILED(rv)) return rv; + + return CallQueryInterface(localFile, result); } //---------------------------------------------------------------------------- diff --git a/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.h b/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.h index ab11a4eede5..832732f1d08 100644 --- a/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.h +++ b/mozilla/netwerk/protocol/res/src/nsResProtocolHandler.h @@ -62,8 +62,6 @@ private: nsSupportsHashtable mSubstitutions; nsCOMPtr mIOService; - - friend class nsResURL; }; #endif /* nsResProtocolHandler_h___ */ diff --git a/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp b/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp index 6e0f52d2d63..44295531c43 100644 --- a/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp +++ b/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp @@ -246,9 +246,9 @@ FileSystemDataSource::isDirURI(nsIRDFResource* source) rv = source->GetValueConst(&uri); if (NS_FAILED(rv)) return(PR_FALSE); - nsCOMPtr aDir; + nsCOMPtr aDir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); - rv = NS_GetFileFromURLSpec(nsDependentCString(uri), getter_AddRefs(aDir)); + rv = NS_InitFileFromURLSpec(aDir, nsDependentCString(uri)); if (NS_FAILED(rv)) return(PR_FALSE); PRBool isDirFlag = PR_FALSE; diff --git a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp index 19c23d4c4f9..1c966cb98c1 100644 --- a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp @@ -763,11 +763,10 @@ nsGlobalHistory::AddNewPageToDatabase(const char *aURL, SetRowValue(row, kToken_LastVisitDateColumn, aDate); SetRowValue(row, kToken_FirstVisitDateColumn, aDate); - nsCOMPtr uri; - NS_NewURI(getter_AddRefs(uri), nsDependentCString(aURL), nsnull, nsnull); nsCAutoString hostname; - if (uri) - uri->GetHost(hostname); + nsCOMPtr ioService = do_GetService(NS_IOSERVICE_CONTRACTID); + if (!ioService) return NS_ERROR_FAILURE; + ioService->ExtractUrlPart(nsDependentCString(aURL), nsIIOService::url_Host, hostname); SetRowValue(row, kToken_HostnameColumn, hostname.get()); diff --git a/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp b/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp index f39d9cc14f2..299b35c44ae 100644 --- a/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp +++ b/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp @@ -653,27 +653,18 @@ nsUrlbarHistory::VerifyAndCreateEntry(const PRUnichar * aSearchItem, const PRUni searchStrLen = nsCRT::strlen(aSearchItem); nsresult rv; - nsCOMPtr uri; - NS_NewURI(getter_AddRefs(uri), NS_ConvertUCS2toUTF8(aSearchItem)); nsCAutoString filePath; - if (uri) { - nsCOMPtr url(do_QueryInterface(uri)); - if (url) - url->GetFilePath(filePath); - } - + nsCOMPtr ioService = do_GetService(NS_IOSERVICE_CONTRACTID); + if (!ioService) return NS_ERROR_FAILURE; + ioService->ExtractUrlPart(NS_ConvertUCS2toUTF8(aSearchItem), nsIIOService::url_Path, filePath); + // Don't bother checking for hostname if the search string // already has a filepath; if (filePath.Length() > 1) { return NS_OK; } - - NS_NewURI(getter_AddRefs(uri), NS_ConvertUCS2toUTF8(aMatchStr)); - if (uri) { - nsCOMPtr url(do_QueryInterface(uri)); - if (url) - url->GetFilePath(filePath); - } + + ioService->ExtractUrlPart(NS_ConvertUCS2toUTF8(aMatchStr), nsIIOService::url_Path, filePath); // If the match string doesn't have a filepath // we need to do nothing here, return.