зеркало из https://github.com/mozilla/pjs.git
Bug 332147 - Expose nsEscape on a scriptable interface, r=darin
This commit is contained in:
Родитель
b21b4b195e
Коммит
e2b1353329
|
@ -21,6 +21,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Boris Zbarsky <bzbarsky@mit.edu> (original author)
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -41,7 +42,7 @@
|
|||
/**
|
||||
* nsINetUtil provides various network-related utility methods.
|
||||
*/
|
||||
[scriptable, uuid(f0c5dddb-4713-4603-af2d-bf671838996b)]
|
||||
[scriptable, uuid(e379f39e-80bd-4ac5-a35a-27e7739f837d)]
|
||||
interface nsINetUtil : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -57,4 +58,23 @@ interface nsINetUtil : nsISupports
|
|||
AUTF8String parseContentType(in AUTF8String aTypeHeader,
|
||||
out AUTF8String aCharset,
|
||||
out boolean aHadCharset);
|
||||
|
||||
/** Escape every character with its %XX-escaped equivalent */
|
||||
const unsigned long ESCAPE_ALL = 0;
|
||||
|
||||
/** Leave alphanumeric characters intact and %XX-escape all others */
|
||||
const unsigned long ESCAPE_XALPHAS = 1;
|
||||
|
||||
/** Leave alphanumeric characters intact, convert spaces to '+',
|
||||
%XX-escape all others */
|
||||
const unsigned long ESCAPE_XPALPHAS = 2;
|
||||
|
||||
/** Leave alphanumeric characters and forward slashes intact,
|
||||
%XX-escape all others */
|
||||
const unsigned long ESCAPE_URL_PATH = 3;
|
||||
|
||||
/**
|
||||
* escape a string with %00-style escaping
|
||||
*/
|
||||
ACString escapeString(in ACString aString, in unsigned long aEscapeType);
|
||||
};
|
||||
|
|
|
@ -833,3 +833,21 @@ nsIOService::TrackNetworkLinkStatusForOffline()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return SetOffline(!isUp);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIOService::EscapeString(const nsACString& aString,
|
||||
PRUint32 aEscapeType,
|
||||
nsACString& aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_RANGE(aEscapeType, 0, 3);
|
||||
|
||||
nsCAutoString stringCopy(aString);
|
||||
nsCString result;
|
||||
|
||||
if (!NS_Escape(stringCopy, result, (nsEscapeMask) aEscapeType))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
aResult.Assign(result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
|
||||
/**
|
||||
* Valid mask values for nsEscape
|
||||
* Note: these values are copied in nsINetUtil.idl. Any changes should be kept
|
||||
* in sync.
|
||||
*/
|
||||
typedef enum {
|
||||
url_All = 0 /**< %-escape every byte uncondtionally */
|
||||
|
|
Загрузка…
Ссылка в новой задаче