NetSurf
|
Implementation of URI percent escaping. More...
#include <ctype.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include "utils/ascii.h"
#include "utils/config.h"
#include "utils/log.h"
#include "utils/url.h"
Go to the source code of this file.
Functions | |
static char | xdigit_to_hex (char c) |
Convert a hex digit to a hex value. More... | |
nserror | url_unescape (const char *str, size_t length, size_t *length_out, char **result_out) |
Convert an escaped string to plain. More... | |
nserror | url_escape (const char *unescaped, bool sptoplus, const char *escexceptions, char **result) |
Escape a string suitable for inclusion in an URL. More... | |
Implementation of URI percent escaping.
Percent encoding of URI is subject to RFC3986 however this is not implementing URI behaviour purely the percent encoding so only the unreserved set is not encoded and arbitrary binary data may be unescaped.
Definition in file url.c.
nserror url_escape | ( | const char * | unescaped, |
bool | sptoplus, | ||
const char * | escexceptions, | ||
char ** | result | ||
) |
Escape a string suitable for inclusion in an URL.
[in] | unescaped | the unescaped string |
[in] | sptoplus | true iff spaces should be converted to + |
[in] | escexceptions | NULL or a string of characters to be excluded from escaping. |
[out] | result | Returns pointer to buffer to escaped string. Returned string is '\0' terminated. |
Definition at line 131 of file url.c.
References NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_OK, and result.
Referenced by atari_path_to_nsurl(), form_url_encode(), make_search_nsurl(), posix_path_to_nsurl(), and ro_path_to_nsurl().
nserror url_unescape | ( | const char * | str, |
size_t | length, | ||
size_t * | length_out, | ||
char ** | result_out | ||
) |
Convert an escaped string to plain.
[in] | str | String to unescape. |
[in] | length | Length of string or 0 to use strlen. |
[out] | length_out | Iff non-NULL, value updated to length of returned result_out string (excluding trailing '\0'`). |
[out] | result_out | Returns unescaped string, owned by caller. Must be freed with free(). Returned string has trailing '\0'. |
Definition at line 67 of file url.c.
References ascii_is_hex(), NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_OK, result, and xdigit_to_hex().
Referenced by amiga_nsurl_to_path(), atari_nsurl_to_path(), download_ro_filetype(), fetch_data_process(), posix_nsurl_to_path(), ro_nsurl_to_path(), url_to_path(), and windows_nsurl_to_path().
|
inlinestatic |
Convert a hex digit to a hex value.
Must be called with valid hex char, results undefined otherwise.
[in] | c | character to convert to value |
Definition at line 54 of file url.c.
Referenced by url_unescape().