19#include <sys/socket.h>
27#define MSG(...) printf("[dpiutil.c]: " __VA_ARGS__)
38 static const char *esc_set, *hex =
"0123456789ABCDEF";
43 esc_set = (p_esc_set) ? p_esc_set :
"%#:' ";
45 for (i = 0; str[i]; ++i) {
46 if (str[i] <= 0x1F || str[i] == 0x7F || strchr(esc_set, str[i])) {
69 for (p = buf; (*p = *s); ++s, ++p) {
70 if (*p ==
'%' && isxdigit(s[1]) && isxdigit(s[2])) {
71 *p = (isdigit(s[1]) ? (s[1] -
'0')
73 *p += isdigit(s[2]) ? (s[2] -
'0')
86 {
"&",
"<",
">",
""",
"'" };
99 for (i = 0; str[i]; ++i) {
120 if (!strchr(str,
'&'))
123 for (i = 0, j = 0; str[i]; ++i) {
125 for (k = 0; k < 5; ++k) {
153 if (strlen(url) > 6) {
154 for (i = 6; (c = url[i]) && c !=
'/'; ++i) {
155 if (c ==
'\n' || c ==
'\r') {
156 memmove(url + i, url + i + 1, strlen(url + i));
158 }
else if (c ==
'%' && url[i+1] ==
'0' &&
161 memmove(url + i, url + i + 3, strlen(url + i + 2));
void dStr_append(Dstr *ds, const char *s)
Append a C string to a Dstr.
char * dStrdup(const char *s)
Dstr * dStr_sized_new(int sz)
Create a new string with a given size.
int dStrnAsciiCasecmp(const char *s1, const char *s2, size_t n)
void dStr_free(Dstr *ds, int all)
Free a dillo string.
void dStr_append_c(Dstr *ds, int c)
Append one character.
#define D_ASCII_TOLOWER(c)
#define D_ASCII_TOUPPER(c)
char * Escape_html_str(const char *str)
static const char * unsafe_chars
char * Filter_smtp_hack(char *url)
static const int unsafe_rep_len[]
char * Unescape_uri_str(const char *s)
char * Unescape_html_str(const char *str)
char * Escape_uri_str(const char *str, const char *p_esc_set)
static const char * unsafe_rep[]