Enumerations | Functions

nsEscape.h File Reference

#include "prtypes.h"
#include "nscore.h"
#include "nsError.h"
#include "nsString.h"
Include dependency graph for nsEscape.h:

Enumerations

enum  nsEscapeMask { url_All = 0, url_XAlphas = ((PRUint32)1 << ( 0 )), url_XPAlphas = ((PRUint32)1 << ( 1 )), url_Path = ((PRUint32)1 << ( 2 )) }
 

Valid mask values for nsEscape Note: these values are copied in nsINetUtil.idl.

More...
enum  EscapeMask {
  esc_Scheme = ((PRUint32)1 << ( 0 )), esc_Username = ((PRUint32)1 << ( 1 )), esc_Password = ((PRUint32)1 << ( 2 )), esc_Host = ((PRUint32)1 << ( 3 )),
  esc_Directory = ((PRUint32)1 << ( 4 )), esc_FileBaseName = ((PRUint32)1 << ( 5 )), esc_FileExtension = ((PRUint32)1 << ( 6 )), esc_FilePath = esc_Directory | esc_FileBaseName | esc_FileExtension,
  esc_Param = ((PRUint32)1 << ( 7 )), esc_Query = ((PRUint32)1 << ( 8 )), esc_Ref = ((PRUint32)1 << ( 9 )), esc_Minimal = esc_Scheme | esc_Username | esc_Password | esc_Host | esc_FilePath | esc_Param | esc_Query | esc_Ref,
  esc_Forced = ((PRUint32)1 << ( 10 )), esc_OnlyASCII = ((PRUint32)1 << ( 11 )), esc_OnlyNonASCII = ((PRUint32)1 << ( 12 )), esc_AlwaysCopy = ((PRUint32)1 << ( 13 )),
  esc_Colon = ((PRUint32)1 << ( 14 )), esc_SkipControl = ((PRUint32)1 << ( 15 ))
}
 

NS_EscapeURL/NS_UnescapeURL constants for |flags| parameter:

More...

Functions

char * nsEscape (const char *str, nsEscapeMask mask)
 Escape the given string according to mask.
char * nsUnescape (char *str)
PRInt32 nsUnescapeCount (char *str)
char * nsEscapeHTML (const char *string)
PRUnicharnsEscapeHTML2 (const PRUnichar *aSourceBuffer, PRInt32 aSourceBufferLen=-1)
PRBool NS_EscapeURL (const char *str, PRInt32 len, PRUint32 flags, nsACString &result)
 NS_EscapeURL.
PRBool NS_UnescapeURL (const char *str, PRInt32 len, PRUint32 flags, nsACString &result)
 Expands URL escape sequences...
PRInt32 NS_UnescapeURL (char *str)
 returns resultant string length
const nsCSubstringNS_EscapeURL (const nsCSubstring &str, PRUint32 flags, nsCSubstring &result)
 String friendly versions...
const nsCSubstringNS_UnescapeURL (const nsCSubstring &str, PRUint32 flags, nsCSubstring &result)
PRBool NS_Escape (const nsCString &aOriginal, nsCString &aEscaped, nsEscapeMask aMask)
 CString version of nsEscape.
nsCString & NS_UnescapeURL (nsCString &str)
 Inline unescape of mutable string object.

Enumeration Type Documentation

enum EscapeMask

NS_EscapeURL/NS_UnescapeURL constants for |flags| parameter:

Note: These values are copied to nsINetUtil.idl Any changes should be kept in sync

Enumerator:
esc_Scheme 

url components

esc_Username 
esc_Password 
esc_Host 
esc_Directory 
esc_FileBaseName 
esc_FileExtension 
esc_FilePath 
esc_Param 
esc_Query 
esc_Ref 
esc_Minimal 

special flags

esc_Forced 
esc_OnlyASCII 
esc_OnlyNonASCII 
esc_AlwaysCopy 
esc_Colon 
esc_SkipControl 

Valid mask values for nsEscape Note: these values are copied in nsINetUtil.idl.

Any changes should be kept in sync.

Enumerator:
url_All 

-escape every byte uncondtionally

url_XAlphas 

Normal escape - leave alphas intact, escape the rest.

url_XPAlphas 

As url_XAlphas, but convert spaces (0x20) to '+' and plus to 2B.

url_Path 

As url_XAlphas, but don't escape slash ('/').


Function Documentation

PRBool NS_Escape ( const nsCString &  aOriginal,
nsCString &  aEscaped,
nsEscapeMask  aMask 
) [inline]

CString version of nsEscape.

Returns true on success, false on out of memory. To reverse this function, use NS_UnescapeURL.

PRBool NS_EscapeURL ( const char *  str,
PRInt32  len,
PRUint32  flags,
nsACString result 
)

NS_EscapeURL.

Escapes invalid char's in an URL segment. Has no side-effect if the URL segment is already escaped. Otherwise, the escaped URL segment is appended to |result|.

Parameters:
str url segment string
len url segment string length (-1 if unknown)
flags url segment type flag
result result buffer, untouched if part is already escaped
Returns:
TRUE if escaping was performed, FALSE otherwise.
const nsCSubstring& NS_EscapeURL ( const nsCSubstring str,
PRUint32  flags,
nsCSubstring result 
) [inline]

String friendly versions...

PRInt32 NS_UnescapeURL ( char *  str  )  [inline]

returns resultant string length

const nsCSubstring& NS_UnescapeURL ( const nsCSubstring str,
PRUint32  flags,
nsCSubstring result 
) [inline]
PRBool NS_UnescapeURL ( const char *  str,
PRInt32  len,
PRUint32  flags,
nsACString result 
)

Expands URL escape sequences...

beware embedded null bytes!

Parameters:
str url string to unescape
len length of |str|
flags only esc_OnlyNonASCII, esc_SkipControl and esc_AlwaysCopy are recognized
result result buffer, untouched if |str| is already unescaped
Returns:
TRUE if unescaping was performed, FALSE otherwise.
nsCString& NS_UnescapeURL ( nsCString &  str  )  [inline]

Inline unescape of mutable string object.

char* nsEscape ( const char *  str,
nsEscapeMask  mask 
)

Escape the given string according to mask.

Parameters:
str The string to escape
mask How to escape the string
Returns:
A newly allocated escaped string that must be free'd with nsCRT::free, or null on failure
char* nsEscapeHTML ( const char *  string  ) 
PRUnichar* nsEscapeHTML2 ( const PRUnichar aSourceBuffer,
PRInt32  aSourceBufferLen = -1 
)
char* nsUnescape ( char *  str  ) 
PRInt32 nsUnescapeCount ( char *  str  )