Apache HTTPD
Macros | Functions | Variables
Escape functions

Macros

#define APR_ESCAPE_STRING   (-1)
 
#define APR_ESCAPE_LDAP_DN   (0x01)
 
#define APR_ESCAPE_LDAP_FILTER   (0x02)
 
#define APR_ESCAPE_LDAP_ALL   (0x03)
 

Functions

 APR_DECLARE (apr_status_t) apr_escape_shell(char *escaped
 
 APR_DECLARE (const char *) apr_pescape_shell(apr_pool_t *p
 
const char *str __attribute__ ((nonnull(1)))
 
 APR_DECLARE (const void *) apr_punescape_hex(apr_pool_t *p
 

Variables

const charstr
 
const char apr_ssize_t slen
 
const char apr_ssize_t apr_size_tlen
 
const charurl
 
const char apr_ssize_t const charforbid
 
const char apr_ssize_t const char const charreserved
 
const char apr_ssize_t const char const char int plus
 
const charpath
 
const char apr_ssize_t int partial
 
const char apr_ssize_t int toasc
 
const char apr_ssize_t int quote
 
const void * src
 
const void apr_size_t srclen
 
const void apr_size_t int colon
 
const void apr_ssize_t int flags
 

Detailed Description

Macro Definition Documentation

◆ APR_ESCAPE_LDAP_ALL

#define APR_ESCAPE_LDAP_ALL   (0x03)

Apply both RFC4514 and RFC4515 LDAP escaping.

Definition at line 71 of file apr_escape.h.

◆ APR_ESCAPE_LDAP_DN

#define APR_ESCAPE_LDAP_DN   (0x01)

Apply LDAP distinguished name escaping as per RFC4514.

Definition at line 61 of file apr_escape.h.

◆ APR_ESCAPE_LDAP_FILTER

#define APR_ESCAPE_LDAP_FILTER   (0x02)

Apply LDAP filter escaping as per RFC4515.

Definition at line 66 of file apr_escape.h.

◆ APR_ESCAPE_STRING

#define APR_ESCAPE_STRING   (-1)

When passing a string to one of the escape functions, this value can be passed to indicate a string-valued key, and have the length computed automatically.

Definition at line 56 of file apr_escape.h.

Function Documentation

◆ __attribute__()

const void apr_ssize_t int flags __attribute__ ( (nonnull(1))  )

◆ APR_DECLARE() [1/3]

APR_DECLARE ( apr_status_t  )

Perform shell escaping on the provided string.

Shell escaping causes characters to be prefixed with a '\' character.

Parameters
escapedOptional buffer to write the encoded string, can be NULL
strThe original string
slenThe length of the original string, or APR_ESCAPE_STRING
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if no changes to the string were detected or the string was NULL

Unescapes a URL, leaving reserved characters intact.

Parameters
escapedOptional buffer to write the encoded string, can be NULL
urlString to be unescaped
slenThe length of the original url, or APR_ESCAPE_STRING
forbidOptional list of forbidden characters, in addition to 0x00
reservedOptional list of reserved characters that will be left unescaped
plusIf non zero, '+' is converted to ' ' as per application/x-www-form-urlencoded encoding
lenIf set, the length of the escaped string will be returned
Returns
APR_SUCCESS on success, APR_NOTFOUND if no characters are decoded or the string is NULL, APR_EINVAL if a bad escape sequence is found, APR_BADCH if a character on the forbid list is found.

Escape a path segment, as defined in RFC1808.

Parameters
escapedOptional buffer to write the encoded string, can be NULL
strThe original string
slenThe length of the original string, or APR_ESCAPE_STRING
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if no changes to the string were detected or the string was NULL

Converts an OS path to a URL, in an OS dependent way, as defined in RFC1808. In all cases if a ':' occurs before the first '/' in the URL, the URL should be prefixed with "./" (or the ':' escaped). In the case of Unix, this means leaving '/' alone, but otherwise doing what escape_path_segment() does. For efficiency reasons, we don't use escape_path_segment(), which is provided for reference. Again, RFC 1808 is where this stuff is defined.

If partial is set, os_escape_path() assumes that the path will be appended to something with a '/' in it (and thus does not prefix "./").

Parameters
escapedOptional buffer to write the encoded string, can be NULL
pathThe original string
slenThe length of the original string, or APR_ESCAPE_STRING
partialIf non zero, suppresses the prepending of "./"
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if no changes to the string were detected or if the string was NULL

Urlencode a string, as defined in http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1.

Parameters
escapedOptional buffer to write the encoded string, can be NULL
strThe original string
slenThe length of the original string, or APR_ESCAPE_STRING
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if no changes to the string were detected or if the stirng was NULL

Apply entity encoding to a string. Characters are replaced as follows: '<' becomes '&lt;', '>' becomes '&gt;', '&' becomes '&amp;', the double quote becomes '&quot;" and the single quote becomes '&apos;'.

If toasc is not zero, any non ascii character will be encoded as '%#ddd;', where ddd is the decimal code of the character.

Parameters
escapedOptional buffer to write the encoded string, can be NULL
strThe original string
slenThe length of the original string, or APR_ESCAPE_STRING
toascIf non zero, encode non ascii characters
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if no changes to the string were detected or the string was NULL

Decodes html entities or numeric character references in a string. If the string to be unescaped is syntactically incorrect, then the following fixups will be made: unknown entities will be left undecoded; references to unused numeric characters will be deleted. In particular, &#00; will not be decoded, but will be deleted.

Parameters
unescapedOptional buffer to write the encoded string, can be NULL
strThe original string
slenThe length of the original string, or APR_ESCAPE_STRING
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if no changes to the string were detected or the string was NULL

Escape control characters in a string, as performed by the shell's 'echo' command. Characters are replaced as follows: \a alert (bell), \b backspace, \f form feed, \n new line, \r carriage return, \t horizontal tab, \v vertical tab, \ backslash.

Any non ascii character will be encoded as '\xHH', where HH is the hex code of the character.

If quote is not zero, the double quote character will also be escaped.

Parameters
escapedOptional buffer to write the encoded string, can be NULL
strThe original string
slenThe length of the original string, or APR_ESCAPE_STRING
quoteIf non zero, encode double quotes
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if no changes to the string were detected or the string was NULL

Convert binary data to a hex encoding.

Parameters
destThe destination buffer, can be NULL
srcThe original buffer
srclenThe length of the original buffer
colonIf not zero, insert colon characters between hex digits.
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if the string was NULL

Convert hex encoded string to binary data.

Parameters
destThe destination buffer, can be NULL
strThe original buffer
slenThe length of the original buffer
colonIf not zero, ignore colon characters between hex digits.
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if the string was NULL, or APR_BADCH if a non hex character is present.

Apply LDAP escaping to binary data. Characters from RFC4514 and RFC4515 are escaped with their hex equivalents.

Parameters
destThe destination buffer, can be NULL
srcThe original buffer
srclenThe length of the original buffer
flagsAPR_ESCAPE_LDAP_DN for RFC4514, APR_ESCAPE_LDAP_FILTER for RFC4515, APR_ESCAPE_LDAP_ALL for both
lenIf present, returns the length of the string
Returns
APR_SUCCESS, or APR_NOTFOUND if the string was NULL

< File is read-only

< File is executable

< all protections

< File is read-only

< File is read-only

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< File is executable

< File is executable

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Stat the link not the file itself if it is a link

< Stat the link not the file itself if it is a link

< ->name in proper case

< ->name in proper case

< Access Time

< Create the file if not there

< Open the file for reading

< Open the file for writing

< Delete the file after close

< Open should fail if APR_FOPEN_CREATE and file exists.

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Read by user

<

Deprecated:
See also
APR_FPROT_UREAD

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< ->name in proper case

< Modification Time

< Access Time

< Creation or inode-changed time

< Type

< Size of the file

< Storage size consumed by the file

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< ->name in proper case

< ->name in proper case

< Type

< all protections

< ->name in proper case

< ->name in proper case

< File is read-only

< File is hidden

< File is read-only

< File is read-only

< File is hidden

< File is hidden

< Platform dependent flag to enable * non blocking file io

< Open the file for reading

< Open the file for writing

< Open the file for reading

< Open the file for writing

< Open the file for buffered I/O

< Create the file if not there

< Open should fail if APR_FOPEN_CREATE and file exists.

< Open the file and truncate to 0 length

< Open should fail if APR_FOPEN_CREATE and file exists.

< Create the file if not there

< Open the file and truncate to 0 length

< Append to the end of the file

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Delete the file after close

< Open the file for buffered I/O

< Open the file for writing

< Open the file for writing

< Open the file for reading

< Append to the end of the file

< an atomic unix apr_stat()

< Open the file for writing

< Create the file if not there

< Open the file and truncate to 0 length

< Open the file for writing

< Create the file if not there

< Append to the end of the file

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< File is read-only

< File is executable

< all protections

< File is read-only

< File is read-only

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< File is executable

< File is executable

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Access Time

< Stat the link not the file itself if it is a link

< Stat the link not the file itself if it is a link

< Stat the link not the file itself if it is a link

< Create the file if not there

< Open the file for reading

< Open the file for writing

< Open should fail if APR_FOPEN_CREATE and file exists.

< Delete the file after close

< Open the file for reading

< Open the file for writing

< Open the file for reading

< Open the file for writing

< Create the file if not there

< Open should fail if APR_FOPEN_CREATE and file exists.

< Open should fail if APR_FOPEN_CREATE and file exists.

< Create the file if not there

< Append to the end of the file

< Open the file and truncate to 0 length

< Platform dependent flag to enable * non blocking file io

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Open the file for buffered I/O

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Open the file for buffered I/O

< Open the file for writing

< Open the file for writing

< Open the file for reading

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

The problem with trying to output the entire iovec is that we cannot maintain the behaviour that a real writev would have. If we iterate over the iovec one at a time, we lose the atomic properties of writev(). The other option is to combine the entire iovec into one buffer that we could then send in one call to write(). This is not reasonable since we do not know how much data an iovec could contain.

The only reasonable option, that maintains the semantics of a real writev(), is to only write the first iovec. Callers of file_writev() must deal with partial writes as they normally would. If you want to ensure an entire iovec is written, use apr_file_writev_full().

< ->name in proper case

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Size of the file

< Size of the file

< dev and inode

< Number of links

< ->name in proper case

< Type

< Type

< ->name in proper case

< File is read-only

< File is hidden

< File is read-only

< File is read-only

< File is hidden

< File is hidden

< Open the file for reading

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

< Platform dependent flag to enable * non blocking file io

< Open the file for reading

< Open the file for writing

< Create the file if not there

< Open should fail if APR_FOPEN_CREATE and file exists.

< Open the file and truncate to 0 length

< Open the file and truncate to 0 length

< Open should fail if APR_FOPEN_CREATE and file exists.

< Create the file if not there

< Delete the file after close

< Open the file for reading

< Open the file for writing

< Platform dependent tag to open the file for use across multiple threads

< Append to the end of the file

< Open the file for buffered I/O

< Platform dependent flag to enable * sparse file support, see WARNING below

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Append to the end of the file

< Open the file for buffered I/O

< Open the file for writing

< Open the file for writing

< Open the file for reading

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Exclusive lock. Only one process may hold an exclusive lock at any given time. This is analogous to a "write lock".

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Size of the file

< Platform dependent tag to open the file for use across multiple threads

< Size of the file

Definition at line 74 of file apr_atomic.c.

◆ APR_DECLARE() [2/3]

APR_DECLARE ( const char )

Perform shell escaping on the provided string, returning the result from the pool.

Shell escaping causes characters to be prefixed with a '\' character.

If no characters were escaped, the original string is returned.

Parameters
pPool to allocate from
strThe original string
Returns
the encoded string, allocated from the pool, or the original string if no escaping took place or the string was NULL.

Unescapes a URL, leaving reserved characters intact, returning the result from a pool.

Parameters
pPool to allocate from
urlString to be unescaped in place
forbidOptional list of forbidden characters, in addition to 0x00
reservedOptional list of reserved characters that will be left unescaped
plusIf non zero, '+' is converted to ' ' as per application/x-www-form-urlencoded encoding
Returns
A string allocated from the pool on success, the original string if no characters are decoded, or NULL if a bad escape sequence is found or if a character on the forbid list is found, or if the original string was NULL.

Escape a path segment, as defined in RFC1808, returning the result from a pool.

Parameters
pPool to allocate from
strString to be escaped
Returns
A string allocated from the pool on success, the original string if no characters are encoded or the string is NULL.

Converts an OS path to a URL, in an OS dependent way, as defined in RFC1808, returning the result from a pool.

In all cases if a ':' occurs before the first '/' in the URL, the URL should be prefixed with "./" (or the ':' escaped). In the case of Unix, this means leaving '/' alone, but otherwise doing what escape_path_segment() does. For efficiency reasons, we don't use escape_path_segment(), which is provided for reference. Again, RFC 1808 is where this stuff is defined.

If partial is set, os_escape_path() assumes that the path will be appended to something with a '/' in it (and thus does not prefix "./").

Parameters
pPool to allocate from
strThe original string
partialIf non zero, suppresses the prepending of "./"
Returns
A string allocated from the pool on success, the original string if no characters are encoded or if the string was NULL.

Urlencode a string, as defined in http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1, returning the result from a pool.

Parameters
pPool to allocate from
strString to be escaped
Returns
A string allocated from the pool on success, the original string if no characters are encoded or if the string was NULL.

Apply entity encoding to a string, returning the result from a pool. Characters are replaced as follows: '<' becomes '&lt;', '>' becomes '&gt;', '&' becomes '&amp;', the double quote becomes '&quot;" and the single quote becomes '&apos;'.

Parameters
pPool to allocate from
strThe original string
toascIf non zero, encode non ascii characters
Returns
A string allocated from the pool on success, the original string if no characters are encoded or the string is NULL.

Decodes html entities or numeric character references in a string. If the string to be unescaped is syntactically incorrect, then the following fixups will be made: unknown entities will be left undecoded; references to unused numeric characters will be deleted. In particular, &#00; will not be decoded, but will be deleted.

Parameters
pPool to allocate from
strThe original string
Returns
A string allocated from the pool on success, the original string if no characters are encoded or the string is NULL.

Escape control characters in a string, as performed by the shell's 'echo' command, and return the results from a pool. Characters are replaced as follows: \a alert (bell), \b backspace, \f form feed, \n new line, \r carriage return, \t horizontal tab, \v vertical tab, \ backslash.

Any non ascii character will be encoded as '\xHH', where HH is the hex code of the character.

If quote is not zero, the double quote character will also be escaped.

Parameters
pPool to allocate from
strThe original string
quoteIf non zero, encode double quotes
Returns
A string allocated from the pool on success, the original string if no characters are encoded or the string is NULL.

Convert binary data to a hex encoding, and return the results from a pool.

Parameters
pPool to allocate from
srcThe original buffer
slenThe length of the original buffer
colonIf not zero, insert colon characters between hex digits.
Returns
A zero padded buffer allocated from the pool on success, or NULL if src was NULL.

Apply LDAP escaping to binary data, and return the results from a pool. Characters from RFC4514 and RFC4515 are escaped with their hex equivalents.

Parameters
pPool to allocate from
srcThe original buffer
slenThe length of the original buffer
flagsAPR_ESCAPE_LDAP_DN for RFC4514, APR_ESCAPE_LDAP_FILTER for RFC4515, APR_ESCAPE_LDAP_ALL for both
Returns
A zero padded buffer allocated from the pool on success, or NULL if src was NULL.

Definition at line 140 of file dso.c.

◆ APR_DECLARE() [3/3]

APR_DECLARE ( const void *  )

Convert hex encoding to binary data, and return the results from a pool. If the colon character appears between pairs of hex digits, it will be ignored.

Parameters
pPool to allocate from
strThe original string
colonIf not zero, ignore colon characters between hex digits.
lenIf present, returns the length of the final buffer
Returns
A buffer allocated from the pool on success, or NULL if src was NULL, or a bad character was present.

Definition at line 175 of file apr_escape.c.

Variable Documentation

◆ colon

const char int colon

Definition at line 355 of file apr_escape.h.

◆ flags

const void apr_ssize_t int flags

Definition at line 409 of file apr_escape.h.

◆ forbid

const char const char * forbid

Definition at line 121 of file apr_escape.h.

◆ len

Definition at line 86 of file apr_escape.h.

◆ partial

Definition at line 188 of file apr_escape.h.

◆ path

const char* path

Definition at line 187 of file apr_escape.h.

◆ plus

Definition at line 121 of file apr_escape.h.

◆ quote

const char int quote

Definition at line 323 of file apr_escape.h.

◆ reserved

const char const char const char * reserved

Definition at line 121 of file apr_escape.h.

◆ slen

const void apr_ssize_t slen

Definition at line 86 of file apr_escape.h.

◆ src

const void * src

Definition at line 354 of file apr_escape.h.

◆ srclen

const void apr_ssize_t srclen

Definition at line 355 of file apr_escape.h.

◆ str

const char * str

Definition at line 85 of file apr_escape.h.

◆ toasc

Definition at line 254 of file apr_escape.h.

◆ url

const char * url

Definition at line 120 of file apr_escape.h.