Use standard bool types.
I'm using `stdbool.h` for the few remaining C files. That will have to change, soon.
This commit is contained in:
1
d_size.h
1
d_size.h
@ -18,7 +18,6 @@ typedef unsigned char uchar_t;
|
|||||||
typedef unsigned short ushort_t;
|
typedef unsigned short ushort_t;
|
||||||
typedef unsigned long ulong_t;
|
typedef unsigned long ulong_t;
|
||||||
typedef unsigned int uint_t;
|
typedef unsigned int uint_t;
|
||||||
typedef unsigned char bool_t;
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __D_SIZE_H__ */
|
#endif /* __D_SIZE_H__ */
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "dlib.h"
|
#include "dlib.h"
|
||||||
|
|
||||||
static bool_t dLib_show_msg = TRUE;
|
static bool dLib_show_msg = TRUE;
|
||||||
|
|
||||||
/* dlib msgs go to stderr to avoid problems with filter dpis */
|
/* dlib msgs go to stderr to avoid problems with filter dpis */
|
||||||
#define DLIB_MSG(...) \
|
#define DLIB_MSG(...) \
|
||||||
@ -890,7 +890,7 @@ int dParser_parse_rc_line(char **line, char **name, char **value)
|
|||||||
/*
|
/*
|
||||||
*- Dlib messages -------------------------------------------------------------
|
*- Dlib messages -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void dLib_show_messages(bool_t show)
|
void dLib_show_messages(bool show)
|
||||||
{
|
{
|
||||||
dLib_show_msg = show;
|
dLib_show_msg = show;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <stdarg.h> /* for va_list */
|
#include <stdarg.h> /* for va_list */
|
||||||
#include <string.h> /* for strerror */
|
#include <string.h> /* for strerror */
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "d_size.h"
|
#include "d_size.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -175,7 +177,7 @@ int dParser_parse_rc_line(char **line, char **name, char **value);
|
|||||||
/*
|
/*
|
||||||
*- Dlib messages -------------------------------------------------------------
|
*- Dlib messages -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void dLib_show_messages(bool_t show);
|
void dLib_show_messages(bool show);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*- Misc utility functions ----------------------------------------------------
|
*- Misc utility functions ----------------------------------------------------
|
||||||
|
132
dpi/cookies.cc
132
dpi/cookies.cc
@ -103,9 +103,9 @@ typedef struct {
|
|||||||
char *domain;
|
char *domain;
|
||||||
char *path;
|
char *path;
|
||||||
time_t expires_at;
|
time_t expires_at;
|
||||||
bool_t host_only;
|
bool host_only;
|
||||||
bool_t secure;
|
bool secure;
|
||||||
bool_t session_only;
|
bool session_only;
|
||||||
long last_used;
|
long last_used;
|
||||||
} CookieData_t;
|
} CookieData_t;
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ static int num_ccontrol_max = 1;
|
|||||||
static CookieControlAction default_action = COOKIE_DENY;
|
static CookieControlAction default_action = COOKIE_DENY;
|
||||||
|
|
||||||
static long cookies_use_counter = 0;
|
static long cookies_use_counter = 0;
|
||||||
static bool_t disabled;
|
static bool disabled;
|
||||||
static FILE *file_stream;
|
static FILE *file_stream;
|
||||||
static const char *const cookies_txt_header_str =
|
static const char *const cookies_txt_header_str =
|
||||||
"# HTTP Cookie File\n"
|
"# HTTP Cookie File\n"
|
||||||
@ -279,15 +279,15 @@ static void Cookies_load_cookies(FILE *stream)
|
|||||||
char *line_marker = line;
|
char *line_marker = line;
|
||||||
CookieData_t *cookie = dNew0(CookieData_t, 1);
|
CookieData_t *cookie = dNew0(CookieData_t, 1);
|
||||||
|
|
||||||
cookie->session_only = FALSE;
|
cookie->session_only = false;
|
||||||
cookie->domain = dStrdup(dStrsep(&line_marker, "\t"));
|
cookie->domain = dStrdup(dStrsep(&line_marker, "\t"));
|
||||||
piece = dStrsep(&line_marker, "\t");
|
piece = dStrsep(&line_marker, "\t");
|
||||||
if (piece != NULL && piece[0] == 'F')
|
if (piece != NULL && piece[0] == 'F')
|
||||||
cookie->host_only = TRUE;
|
cookie->host_only = true;
|
||||||
cookie->path = dStrdup(dStrsep(&line_marker, "\t"));
|
cookie->path = dStrdup(dStrsep(&line_marker, "\t"));
|
||||||
piece = dStrsep(&line_marker, "\t");
|
piece = dStrsep(&line_marker, "\t");
|
||||||
if (piece != NULL && piece[0] == 'T')
|
if (piece != NULL && piece[0] == 'T')
|
||||||
cookie->secure = TRUE;
|
cookie->secure = true;
|
||||||
piece = dStrsep(&line_marker, "\t");
|
piece = dStrsep(&line_marker, "\t");
|
||||||
if (piece != NULL) {
|
if (piece != NULL) {
|
||||||
/* There is some problem with simply putting the maximum value
|
/* There is some problem with simply putting the maximum value
|
||||||
@ -318,7 +318,7 @@ static void Cookies_load_cookies(FILE *stream)
|
|||||||
Cookies_free_cookie(cookie);
|
Cookies_free_cookie(cookie);
|
||||||
continue;
|
continue;
|
||||||
} else if (action == COOKIE_ACCEPT_SESSION) {
|
} else if (action == COOKIE_ACCEPT_SESSION) {
|
||||||
cookie->session_only = TRUE;
|
cookie->session_only = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save cookie in memory */
|
/* Save cookie in memory */
|
||||||
@ -341,7 +341,7 @@ static void Cookies_init(void)
|
|||||||
struct tm future_tm = {7, 14, 3, 19, 0, 138, 0, 0, 0, 0, 0};
|
struct tm future_tm = {7, 14, 3, 19, 0, 138, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
/* Default setting */
|
/* Default setting */
|
||||||
disabled = TRUE;
|
disabled = true;
|
||||||
|
|
||||||
cookies_epoch_time = mktime(&cookies_epoch_tm);
|
cookies_epoch_time = mktime(&cookies_epoch_tm);
|
||||||
cookies_future_time = mktime(&future_tm);
|
cookies_future_time = mktime(&future_tm);
|
||||||
@ -457,7 +457,7 @@ static void Cookies_save_and_free(void)
|
|||||||
/*
|
/*
|
||||||
* Month parsing
|
* Month parsing
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_get_month(struct tm *tm, const char **str)
|
static bool Cookies_get_month(struct tm *tm, const char **str)
|
||||||
{
|
{
|
||||||
static const char *const months[] =
|
static const char *const months[] =
|
||||||
{ "Jan", "Feb", "Mar",
|
{ "Jan", "Feb", "Mar",
|
||||||
@ -472,10 +472,10 @@ static bool_t Cookies_get_month(struct tm *tm, const char **str)
|
|||||||
_MSG("Found month: %s\n", months[i]);
|
_MSG("Found month: %s\n", months[i]);
|
||||||
tm->tm_mon = i;
|
tm->tm_mon = i;
|
||||||
*str += 3;
|
*str += 3;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -505,47 +505,47 @@ static int Cookies_get_timefield(const char **str)
|
|||||||
* Time parsing: 'time-field ":" time-field ":" time-field'
|
* Time parsing: 'time-field ":" time-field ":" time-field'
|
||||||
* 'time-field = 1*2DIGIT'
|
* 'time-field = 1*2DIGIT'
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_get_time(struct tm *tm, const char **str)
|
static bool Cookies_get_time(struct tm *tm, const char **str)
|
||||||
{
|
{
|
||||||
const char *s = *str;
|
const char *s = *str;
|
||||||
|
|
||||||
if ((tm->tm_hour = Cookies_get_timefield(&s)) == -1)
|
if ((tm->tm_hour = Cookies_get_timefield(&s)) == -1)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (*(s++) != ':')
|
if (*(s++) != ':')
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if ((tm->tm_min = Cookies_get_timefield(&s)) == -1)
|
if ((tm->tm_min = Cookies_get_timefield(&s)) == -1)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (*(s++) != ':')
|
if (*(s++) != ':')
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if ((tm->tm_sec = Cookies_get_timefield(&s)) == -1)
|
if ((tm->tm_sec = Cookies_get_timefield(&s)) == -1)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
*str = s;
|
*str = s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Day parsing: "day-of-month = 1*2DIGIT"
|
* Day parsing: "day-of-month = 1*2DIGIT"
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_get_day(struct tm *tm, const char **str)
|
static bool Cookies_get_day(struct tm *tm, const char **str)
|
||||||
{
|
{
|
||||||
const char *s = *str;
|
const char *s = *str;
|
||||||
|
|
||||||
if ((tm->tm_mday = Cookies_get_timefield(&s)) == -1)
|
if ((tm->tm_mday = Cookies_get_timefield(&s)) == -1)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
*str = s;
|
*str = s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Date parsing: "year = 2*4DIGIT"
|
* Date parsing: "year = 2*4DIGIT"
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_get_year(struct tm *tm, const char **str)
|
static bool Cookies_get_year(struct tm *tm, const char **str)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
const char *s = *str;
|
const char *s = *str;
|
||||||
@ -553,12 +553,12 @@ static bool_t Cookies_get_year(struct tm *tm, const char **str)
|
|||||||
if (isdigit(*s))
|
if (isdigit(*s))
|
||||||
n = *(s++) - '0';
|
n = *(s++) - '0';
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
if (isdigit(*s)) {
|
if (isdigit(*s)) {
|
||||||
n *= 10;
|
n *= 10;
|
||||||
n += *(s++) - '0';
|
n += *(s++) - '0';
|
||||||
} else
|
} else
|
||||||
return FALSE;
|
return false;
|
||||||
if (isdigit(*s)) {
|
if (isdigit(*s)) {
|
||||||
n *= 10;
|
n *= 10;
|
||||||
n += *(s++) - '0';
|
n += *(s++) - '0';
|
||||||
@ -569,7 +569,7 @@ static bool_t Cookies_get_year(struct tm *tm, const char **str)
|
|||||||
}
|
}
|
||||||
if (isdigit(*s)) {
|
if (isdigit(*s)) {
|
||||||
/* Sorry, users of prehistoric software in the year 10000! */
|
/* Sorry, users of prehistoric software in the year 10000! */
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (n >= 70 && n <= 99)
|
if (n >= 70 && n <= 99)
|
||||||
n += 1900;
|
n += 1900;
|
||||||
@ -579,13 +579,13 @@ static bool_t Cookies_get_year(struct tm *tm, const char **str)
|
|||||||
tm->tm_year = n - 1900;
|
tm->tm_year = n - 1900;
|
||||||
|
|
||||||
*str = s;
|
*str = s;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As given in RFC 6265.
|
* As given in RFC 6265.
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_date_delim(char c)
|
static bool Cookies_date_delim(char c)
|
||||||
{
|
{
|
||||||
return (c == '\x09' ||
|
return (c == '\x09' ||
|
||||||
(c >= '\x20' && c <= '\x2F') ||
|
(c >= '\x20' && c <= '\x2F') ||
|
||||||
@ -605,13 +605,13 @@ static bool_t Cookies_date_delim(char c)
|
|||||||
*/
|
*/
|
||||||
static struct tm *Cookies_parse_date(const char *date)
|
static struct tm *Cookies_parse_date(const char *date)
|
||||||
{
|
{
|
||||||
bool_t found_time = FALSE, found_day = FALSE, found_month = FALSE,
|
bool found_time = false, found_day = false, found_month = false,
|
||||||
found_year = FALSE, matched;
|
found_year = false, matched;
|
||||||
struct tm *tm = dNew0(struct tm, 1);
|
struct tm *tm = dNew0(struct tm, 1);
|
||||||
const char *s = date;
|
const char *s = date;
|
||||||
|
|
||||||
while (*s) {
|
while (*s) {
|
||||||
matched = FALSE;
|
matched = false;
|
||||||
|
|
||||||
if (!found_time)
|
if (!found_time)
|
||||||
matched = found_time = Cookies_get_time(tm, &s);
|
matched = found_time = Cookies_get_time(tm, &s);
|
||||||
@ -893,9 +893,9 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date)
|
|||||||
{
|
{
|
||||||
CookieData_t *cookie = NULL;
|
CookieData_t *cookie = NULL;
|
||||||
char *str = cookie_str;
|
char *str = cookie_str;
|
||||||
bool_t first_attr = TRUE;
|
bool first_attr = true;
|
||||||
bool_t max_age = FALSE;
|
bool max_age = false;
|
||||||
bool_t expires = FALSE;
|
bool expires = false;
|
||||||
|
|
||||||
/* Iterate until there is nothing left of the string */
|
/* Iterate until there is nothing left of the string */
|
||||||
while (*str) {
|
while (*str) {
|
||||||
@ -1023,26 +1023,26 @@ static int Cookies_cmp(const void *a, const void *b)
|
|||||||
/*
|
/*
|
||||||
* Is the domain an IP address?
|
* Is the domain an IP address?
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_domain_is_ip(const char *domain)
|
static bool Cookies_domain_is_ip(const char *domain)
|
||||||
{
|
{
|
||||||
uint_t len;
|
uint_t len;
|
||||||
|
|
||||||
if (!domain)
|
if (!domain)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
len = strlen(domain);
|
len = strlen(domain);
|
||||||
|
|
||||||
if (len == strspn(domain, "0123456789.")) {
|
if (len == strspn(domain, "0123456789.")) {
|
||||||
_MSG("an IPv4 address\n");
|
_MSG("an IPv4 address\n");
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
if (strchr(domain, ':') &&
|
if (strchr(domain, ':') &&
|
||||||
(len == strspn(domain, "0123456789abcdefABCDEF:."))) {
|
(len == strspn(domain, "0123456789abcdefABCDEF:."))) {
|
||||||
/* The precise format is shown in section 3.2.2 of rfc 3986 */
|
/* The precise format is shown in section 3.2.2 of rfc 3986 */
|
||||||
MSG("an IPv6 address\n");
|
MSG("an IPv6 address\n");
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1051,13 +1051,13 @@ static bool_t Cookies_domain_is_ip(const char *domain)
|
|||||||
* Note different user agents apparently vary in path-matching behaviour,
|
* Note different user agents apparently vary in path-matching behaviour,
|
||||||
* but this is the recommended method at the moment.
|
* but this is the recommended method at the moment.
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_path_matches(const char *url_path,
|
static bool Cookies_path_matches(const char *url_path,
|
||||||
const char *cookie_path)
|
const char *cookie_path)
|
||||||
{
|
{
|
||||||
bool_t ret = TRUE;
|
bool ret = true;
|
||||||
|
|
||||||
if (!url_path || !cookie_path) {
|
if (!url_path || !cookie_path) {
|
||||||
ret = FALSE;
|
ret = false;
|
||||||
} else {
|
} else {
|
||||||
uint_t c_len = strlen(cookie_path);
|
uint_t c_len = strlen(cookie_path);
|
||||||
uint_t u_len = strlen(url_path);
|
uint_t u_len = strlen(url_path);
|
||||||
@ -1093,12 +1093,12 @@ static void Cookies_validate_path(CookieData_t *cookie, const char *url_path)
|
|||||||
/*
|
/*
|
||||||
* Check whether host name A domain-matches host name B.
|
* Check whether host name A domain-matches host name B.
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_domain_matches(char *A, char *B)
|
static bool Cookies_domain_matches(char *A, char *B)
|
||||||
{
|
{
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
if (!A || !*A || !B || !*B)
|
if (!A || !*A || !B || !*B)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (*B == '.')
|
if (*B == '.')
|
||||||
B++;
|
B++;
|
||||||
@ -1109,10 +1109,10 @@ static bool_t Cookies_domain_matches(char *A, char *B)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (!dStrAsciiCasecmp(A, B))
|
if (!dStrAsciiCasecmp(A, B))
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
if (Cookies_domain_is_ip(B))
|
if (Cookies_domain_is_ip(B))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
diff = strlen(A) - strlen(B);
|
diff = strlen(A) - strlen(B);
|
||||||
|
|
||||||
@ -1120,7 +1120,7 @@ static bool_t Cookies_domain_matches(char *A, char *B)
|
|||||||
/* B is the tail of A, and the match is preceded by a '.' */
|
/* B is the tail of A, and the match is preceded by a '.' */
|
||||||
return (dStrAsciiCasecmp(A + diff, B) == 0 && A[diff - 1] == '.');
|
return (dStrAsciiCasecmp(A + diff, B) == 0 && A[diff - 1] == '.');
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1178,18 +1178,18 @@ static uint_t Cookies_internal_dots_required(const char *host)
|
|||||||
/*
|
/*
|
||||||
* Validate cookies domain against some security checks.
|
* Validate cookies domain against some security checks.
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_validate_domain(CookieData_t *cookie, char *host)
|
static bool Cookies_validate_domain(CookieData_t *cookie, char *host)
|
||||||
{
|
{
|
||||||
uint_t i, internal_dots;
|
uint_t i, internal_dots;
|
||||||
|
|
||||||
if (!cookie->domain) {
|
if (!cookie->domain) {
|
||||||
cookie->domain = dStrdup(host);
|
cookie->domain = dStrdup(host);
|
||||||
cookie->host_only = TRUE;
|
cookie->host_only = true;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Cookies_domain_matches(host, cookie->domain))
|
if (!Cookies_domain_matches(host, cookie->domain))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
internal_dots = 0;
|
internal_dots = 0;
|
||||||
for (i = 1; i < strlen(cookie->domain) - 1; i++) {
|
for (i = 1; i < strlen(cookie->domain) - 1; i++) {
|
||||||
@ -1202,11 +1202,11 @@ static bool_t Cookies_validate_domain(CookieData_t *cookie, char *host)
|
|||||||
*/
|
*/
|
||||||
if (internal_dots < Cookies_internal_dots_required(host)) {
|
if (internal_dots < Cookies_internal_dots_required(host)) {
|
||||||
MSG("not enough dots in %s\n", cookie->domain);
|
MSG("not enough dots in %s\n", cookie->domain);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_MSG("host %s and domain %s is all right\n", host, cookie->domain);
|
_MSG("host %s and domain %s is all right\n", host, cookie->domain);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1252,29 +1252,29 @@ static int Cookies_set(char *cookie_string, char *url_host,
|
|||||||
/*
|
/*
|
||||||
* Compare the cookie with the supplied data to see whether it matches
|
* Compare the cookie with the supplied data to see whether it matches
|
||||||
*/
|
*/
|
||||||
static bool_t Cookies_match(CookieData_t *cookie, const char *url_path,
|
static bool Cookies_match(CookieData_t *cookie, const char *url_path,
|
||||||
bool_t host_only_val, bool_t is_tls)
|
bool host_only_val, bool is_tls)
|
||||||
{
|
{
|
||||||
if (cookie->host_only != host_only_val)
|
if (cookie->host_only != host_only_val)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
/* Insecure cookies match both secure and insecure urls, secure
|
/* Insecure cookies match both secure and insecure urls, secure
|
||||||
cookies match only secure urls */
|
cookies match only secure urls */
|
||||||
if (cookie->secure && !is_tls)
|
if (cookie->secure && !is_tls)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!Cookies_path_matches(url_path, cookie->path))
|
if (!Cookies_path_matches(url_path, cookie->path))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
/* It's a match */
|
/* It's a match */
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Cookies_add_matching_cookies(const char *domain,
|
static void Cookies_add_matching_cookies(const char *domain,
|
||||||
const char *url_path,
|
const char *url_path,
|
||||||
bool_t host_only_val,
|
bool host_only_val,
|
||||||
Dlist *matching_cookies,
|
Dlist *matching_cookies,
|
||||||
bool_t is_tls)
|
bool is_tls)
|
||||||
{
|
{
|
||||||
DomainNode *node = reinterpret_cast< DomainNode * >( dList_find_sorted(domains, domain,
|
DomainNode *node = reinterpret_cast< DomainNode * >( dList_find_sorted(domains, domain,
|
||||||
Domain_node_by_domain_cmp) );
|
Domain_node_by_domain_cmp) );
|
||||||
@ -1324,7 +1324,7 @@ static std::string Cookies_get(char *url_host, char *url_path,
|
|||||||
char *domain_str;
|
char *domain_str;
|
||||||
CookieData_t *cookie;
|
CookieData_t *cookie;
|
||||||
Dlist *matching_cookies;
|
Dlist *matching_cookies;
|
||||||
bool_t is_tls, is_ip_addr, host_only_val;
|
bool is_tls, is_ip_addr, host_only_val;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1345,7 +1345,7 @@ static std::string Cookies_get(char *url_host, char *url_path,
|
|||||||
* attrs can have leading dots, which should be ignored for matching
|
* attrs can have leading dots, which should be ignored for matching
|
||||||
* purposes.
|
* purposes.
|
||||||
*/
|
*/
|
||||||
host_only_val = FALSE;
|
host_only_val = false;
|
||||||
if (!is_ip_addr) {
|
if (!is_ip_addr) {
|
||||||
/* e.g., sub.example.com set a cookie with domain ".sub.example.com". */
|
/* e.g., sub.example.com set a cookie with domain ".sub.example.com". */
|
||||||
domain_str = dStrconcat(".", url_host, NULL);
|
domain_str = dStrconcat(".", url_host, NULL);
|
||||||
@ -1353,11 +1353,11 @@ static std::string Cookies_get(char *url_host, char *url_path,
|
|||||||
matching_cookies, is_tls);
|
matching_cookies, is_tls);
|
||||||
dFree(domain_str);
|
dFree(domain_str);
|
||||||
}
|
}
|
||||||
host_only_val = TRUE;
|
host_only_val = true;
|
||||||
/* e.g., sub.example.com set a cookie with no domain attribute. */
|
/* e.g., sub.example.com set a cookie with no domain attribute. */
|
||||||
Cookies_add_matching_cookies(url_host, url_path, host_only_val,
|
Cookies_add_matching_cookies(url_host, url_path, host_only_val,
|
||||||
matching_cookies, is_tls);
|
matching_cookies, is_tls);
|
||||||
host_only_val = FALSE;
|
host_only_val = false;
|
||||||
/* e.g., sub.example.com set a cookie with domain "sub.example.com". */
|
/* e.g., sub.example.com set a cookie with domain "sub.example.com". */
|
||||||
Cookies_add_matching_cookies(url_host, url_path, host_only_val,
|
Cookies_add_matching_cookies(url_host, url_path, host_only_val,
|
||||||
matching_cookies, is_tls);
|
matching_cookies, is_tls);
|
||||||
@ -1422,7 +1422,7 @@ static int Cookie_control_init(void)
|
|||||||
char line[LINE_MAXLEN];
|
char line[LINE_MAXLEN];
|
||||||
char domain[LINE_MAXLEN];
|
char domain[LINE_MAXLEN];
|
||||||
char rule[LINE_MAXLEN];
|
char rule[LINE_MAXLEN];
|
||||||
bool_t enabled = FALSE;
|
bool enabled = false;
|
||||||
|
|
||||||
/* Get a file pointer */
|
/* Get a file pointer */
|
||||||
filename = dStrconcat(dGethomedir(), "/.flenser/cookiesrc", NULL);
|
filename = dStrconcat(dGethomedir(), "/.flenser/cookiesrc", NULL);
|
||||||
|
@ -702,7 +702,7 @@ static int File_send_file(ClientInfo *client)
|
|||||||
const char *unknown_type = "application/octet-stream";
|
const char *unknown_type = "application/octet-stream";
|
||||||
char buf[LBUF], *d_cmd, *name;
|
char buf[LBUF], *d_cmd, *name;
|
||||||
int st, st2, namelen;
|
int st, st2, namelen;
|
||||||
bool_t gzipped = FALSE;
|
bool gzipped = false;
|
||||||
|
|
||||||
if (client->state == st_start) {
|
if (client->state == st_start) {
|
||||||
/* Send DPI command */
|
/* Send DPI command */
|
||||||
@ -719,7 +719,7 @@ static int File_send_file(ClientInfo *client)
|
|||||||
namelen = strlen(client->filename);
|
namelen = strlen(client->filename);
|
||||||
if (namelen > 3 &&
|
if (namelen > 3 &&
|
||||||
!dStrAsciiCasecmp(client->filename + namelen - 3, ".gz")) {
|
!dStrAsciiCasecmp(client->filename + namelen - 3, ".gz")) {
|
||||||
gzipped = TRUE;
|
gzipped = true;
|
||||||
namelen -= 3;
|
namelen -= 3;
|
||||||
}
|
}
|
||||||
/* Content-Type info is based on filename extension (with ".gz" removed).
|
/* Content-Type info is based on filename extension (with ".gz" removed).
|
||||||
|
14
src/IO/IO.cc
14
src/IO/IO.cc
@ -154,11 +154,11 @@ static void IO_close_fd(IOData_t *io, int CloseCode)
|
|||||||
/**
|
/**
|
||||||
* Read data from a file descriptor into a specific buffer
|
* Read data from a file descriptor into a specific buffer
|
||||||
*/
|
*/
|
||||||
static bool_t IO_read(IOData_t *io)
|
static bool IO_read(IOData_t *io)
|
||||||
{
|
{
|
||||||
char Buf[IOBufLen];
|
char Buf[IOBufLen];
|
||||||
ssize_t St;
|
ssize_t St;
|
||||||
bool_t ret = FALSE;
|
bool ret = false;
|
||||||
int io_key = io->Key;
|
int io_key = io->Key;
|
||||||
void *conn = a_Tls_connection(io->FD);
|
void *conn = a_Tls_connection(io->FD);
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ static bool_t IO_read(IOData_t *io)
|
|||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
continue;
|
continue;
|
||||||
} else if (errno == EAGAIN) {
|
} else if (errno == EAGAIN) {
|
||||||
ret = TRUE;
|
ret = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (conn) {
|
if (conn) {
|
||||||
@ -216,10 +216,10 @@ static bool_t IO_read(IOData_t *io)
|
|||||||
/**
|
/**
|
||||||
* Write data, from a specific buffer, into a file descriptor
|
* Write data, from a specific buffer, into a file descriptor
|
||||||
*/
|
*/
|
||||||
static bool_t IO_write(IOData_t *io)
|
static bool IO_write(IOData_t *io)
|
||||||
{
|
{
|
||||||
ssize_t St;
|
ssize_t St;
|
||||||
bool_t ret = FALSE;
|
bool ret = false;
|
||||||
void *conn = a_Tls_connection(io->FD);
|
void *conn = a_Tls_connection(io->FD);
|
||||||
|
|
||||||
_MSG(" IO_write\n");
|
_MSG(" IO_write\n");
|
||||||
@ -233,7 +233,7 @@ static bool_t IO_write(IOData_t *io)
|
|||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
continue;
|
continue;
|
||||||
} else if (errno == EAGAIN) {
|
} else if (errno == EAGAIN) {
|
||||||
ret = TRUE;
|
ret = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (conn) {
|
if (conn) {
|
||||||
@ -264,7 +264,7 @@ static bool_t IO_write(IOData_t *io)
|
|||||||
*/
|
*/
|
||||||
static int IO_callback(IOData_t *io)
|
static int IO_callback(IOData_t *io)
|
||||||
{
|
{
|
||||||
bool_t ret = FALSE;
|
bool ret = false;
|
||||||
|
|
||||||
_MSG("IO_callback:: (%s) FD = %d\n",
|
_MSG("IO_callback:: (%s) FD = %d\n",
|
||||||
(io->Op == IORead) ? "IORead" : "IOWrite", io->FD);
|
(io->Op == IORead) ? "IORead" : "IOWrite", io->FD);
|
||||||
|
@ -16,7 +16,7 @@ extern void a_Http_freeall(void);
|
|||||||
int a_Http_init(void);
|
int a_Http_init(void);
|
||||||
int a_Http_proxy_auth(void);
|
int a_Http_proxy_auth(void);
|
||||||
void a_Http_set_proxy_passwd(const char *str);
|
void a_Http_set_proxy_passwd(const char *str);
|
||||||
void a_Http_connect_done(int fd, bool_t success);
|
void a_Http_connect_done(int fd, bool success);
|
||||||
|
|
||||||
void a_Http_ccc (int Op, int Branch, int Dir, ChainLink *Info,
|
void a_Http_ccc (int Op, int Branch, int Dir, ChainLink *Info,
|
||||||
void *Data1, void *Data2);
|
void *Data1, void *Data2);
|
||||||
|
@ -84,7 +84,7 @@ struct SocketData_t {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
char *host;
|
char *host;
|
||||||
uint_t port;
|
uint_t port;
|
||||||
bool_t https;
|
bool https;
|
||||||
|
|
||||||
int active_conns;
|
int active_conns;
|
||||||
int running_the_queue;
|
int running_the_queue;
|
||||||
@ -97,7 +97,7 @@ struct FdMapEntry_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void Http_socket_enqueue(Server_t *srv, SocketData_t* sock);
|
static void Http_socket_enqueue(Server_t *srv, SocketData_t* sock);
|
||||||
static Server_t *Http_server_get(const char *host, uint_t port, bool_t https);
|
static Server_t *Http_server_get(const char *host, uint_t port, bool https);
|
||||||
static void Http_server_remove(Server_t *srv);
|
static void Http_server_remove(Server_t *srv);
|
||||||
static void Http_connect_socket(ChainLink *Info);
|
static void Http_connect_socket(ChainLink *Info);
|
||||||
static char *Http_get_connect_str(const DilloUrl *url);
|
static char *Http_get_connect_str(const DilloUrl *url);
|
||||||
@ -214,7 +214,7 @@ static void Http_fd_map_remove_entry(int fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void a_Http_connect_done(int fd, bool_t success)
|
void a_Http_connect_done(int fd, bool success)
|
||||||
{
|
{
|
||||||
SocketData_t *sd;
|
SocketData_t *sd;
|
||||||
std::optional< FdMapEntry_t > fme;
|
std::optional< FdMapEntry_t > fme;
|
||||||
@ -222,7 +222,7 @@ void a_Http_connect_done(int fd, bool_t success)
|
|||||||
|
|
||||||
if (fme && (sd = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, fme->skey) ))) {
|
if (fme && (sd = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, fme->skey) ))) {
|
||||||
ChainLink *info = sd->Info;
|
ChainLink *info = sd->Info;
|
||||||
bool_t valid_web = a_Web_valid(sd->web);
|
bool valid_web = a_Web_valid(sd->web);
|
||||||
|
|
||||||
if (success && valid_web) {
|
if (success && valid_web) {
|
||||||
a_Chain_bfcb(OpSend, info, &sd->SockFD, const_cast< void * >( static_cast< const void * >( "FD" ) ));
|
a_Chain_bfcb(OpSend, info, &sd->SockFD, const_cast< void * >( static_cast< const void * >( "FD" ) ));
|
||||||
@ -383,7 +383,7 @@ static std::string Http_make_content_type(const DilloUrl *url)
|
|||||||
/**
|
/**
|
||||||
* Make the http query string
|
* Make the http query string
|
||||||
*/
|
*/
|
||||||
static Dstr *Http_make_query_str(DilloWeb *web, bool_t use_proxy, bool_t use_tls)
|
static Dstr *Http_make_query_str(DilloWeb *web, bool use_proxy, bool use_tls)
|
||||||
{
|
{
|
||||||
char *ptr, *cookies, *referer, *auth;
|
char *ptr, *cookies, *referer, *auth;
|
||||||
const DilloUrl *url = web->url.get();
|
const DilloUrl *url = web->url.get();
|
||||||
@ -668,7 +668,7 @@ static void Http_connect_socket(ChainLink *Info)
|
|||||||
|
|
||||||
if (S->addr_list_idx >= S->addr_list.size() ) {
|
if (S->addr_list_idx >= S->addr_list.size() ) {
|
||||||
MSG("Http_connect_socket ran out of IP addrs to try.\n");
|
MSG("Http_connect_socket ran out of IP addrs to try.\n");
|
||||||
a_Http_connect_done(S->SockFD, FALSE);
|
a_Http_connect_done(S->SockFD, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,7 +752,7 @@ static char *Http_get_connect_str(const DilloUrl *url)
|
|||||||
static void Http_dns_cb(int Status, std::optional< std::vector< std::shared_ptr< DilloHost > > > &addr_list, void *data)
|
static void Http_dns_cb(int Status, std::optional< std::vector< std::shared_ptr< DilloHost > > > &addr_list, void *data)
|
||||||
{
|
{
|
||||||
int SKey = VOIDP2INT(data);
|
int SKey = VOIDP2INT(data);
|
||||||
bool_t clean_up = TRUE;
|
bool clean_up = true;
|
||||||
SocketData_t *S;
|
SocketData_t *S;
|
||||||
Server_t *srv;
|
Server_t *srv;
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ static void Http_dns_cb(int Status, std::optional< std::vector< std::shared_ptr<
|
|||||||
/* Successful DNS answer; save the IP */
|
/* Successful DNS answer; save the IP */
|
||||||
S->addr_list = addr_list.value();
|
S->addr_list = addr_list.value();
|
||||||
S->addr_list_idx = 0;
|
S->addr_list_idx = 0;
|
||||||
clean_up = FALSE;
|
clean_up = false;
|
||||||
srv = Http_server_get(host, S->connect_port,
|
srv = Http_server_get(host, S->connect_port,
|
||||||
(S->flags & HTTP_SOCKET_TLS));
|
(S->flags & HTTP_SOCKET_TLS));
|
||||||
Http_socket_enqueue(srv, S);
|
Http_socket_enqueue(srv, S);
|
||||||
@ -833,7 +833,7 @@ static int Http_get(ChainLink *Info, void *Data1)
|
|||||||
* NOTE: old and new must come from the same Server_t.
|
* NOTE: old and new must come from the same Server_t.
|
||||||
* This is not built to accept arbitrary sockets.
|
* This is not built to accept arbitrary sockets.
|
||||||
*/
|
*/
|
||||||
static bool_t Http_socket_reuse_compatible(SocketData_t *old,
|
static bool Http_socket_reuse_compatible(SocketData_t *old,
|
||||||
SocketData_t *new_)
|
SocketData_t *new_)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -868,11 +868,11 @@ static void Http_socket_reuse(int SKey)
|
|||||||
|
|
||||||
if (!(new_sd->flags & HTTP_SOCKET_TO_BE_FREED) &&
|
if (!(new_sd->flags & HTTP_SOCKET_TO_BE_FREED) &&
|
||||||
Http_socket_reuse_compatible(old_sd, new_sd)) {
|
Http_socket_reuse_compatible(old_sd, new_sd)) {
|
||||||
const bool_t success = TRUE;
|
const bool success = true;
|
||||||
|
|
||||||
new_sd->SockFD = old_sd->SockFD;
|
new_sd->SockFD = old_sd->SockFD;
|
||||||
|
|
||||||
old_sd->connected_to = NULL;
|
old_sd->connected_to = nullptr;
|
||||||
srv->active_conns--;
|
srv->active_conns--;
|
||||||
Http_socket_free(SKey);
|
Http_socket_free(SKey);
|
||||||
|
|
||||||
@ -1068,7 +1068,7 @@ static void Http_socket_enqueue(Server_t *srv, SocketData_t* sock)
|
|||||||
dList_append(srv->queue, sock);
|
dList_append(srv->queue, sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Server_t *Http_server_get(const char *host, uint_t port, bool_t https)
|
static Server_t *Http_server_get(const char *host, uint_t port, bool https)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Server_t *srv;
|
Server_t *srv;
|
||||||
|
@ -82,9 +82,9 @@ typedef struct {
|
|||||||
int fd;
|
int fd;
|
||||||
DilloUrl *url;
|
DilloUrl *url;
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
bool_t connecting;
|
bool connecting;
|
||||||
bool_t in_connect;
|
bool in_connect;
|
||||||
bool_t do_shutdown;
|
bool do_shutdown;
|
||||||
} Conn_t;
|
} Conn_t;
|
||||||
|
|
||||||
/* List of active TLS connections */
|
/* List of active TLS connections */
|
||||||
@ -170,9 +170,9 @@ static int Tls_conn_new(int fd, const DilloUrl *url, SSL *ssl)
|
|||||||
conn->fd = fd;
|
conn->fd = fd;
|
||||||
conn->url = a_Url_dup(url).release();
|
conn->url = a_Url_dup(url).release();
|
||||||
conn->ssl = ssl;
|
conn->ssl = ssl;
|
||||||
conn->connecting = TRUE;
|
conn->connecting = true;
|
||||||
conn->in_connect = FALSE;
|
conn->in_connect = false;
|
||||||
conn->do_shutdown = TRUE;
|
conn->do_shutdown = true;
|
||||||
|
|
||||||
key = a_Klist_insert(&conn_list, conn);
|
key = a_Klist_insert(&conn_list, conn);
|
||||||
|
|
||||||
@ -457,14 +457,14 @@ int a_Tls_openssl_certificate_is_clean(const DilloUrl *url)
|
|||||||
* not good practice, but feels justified by the fact that it's so much
|
* not good practice, but feels justified by the fact that it's so much
|
||||||
* trouble to get this information out of openssl even once.
|
* trouble to get this information out of openssl even once.
|
||||||
*
|
*
|
||||||
* Return FALSE if MD5 (MD*) hash is found and user does not accept it,
|
* Return `false` if MD5 (MD*) hash is found and user does not accept it,
|
||||||
* otherwise TRUE.
|
* otherwise TRUE.
|
||||||
*/
|
*/
|
||||||
static bool_t Tls_check_cert_strength(SSL *ssl, Server_t *srv, int *choice)
|
static bool Tls_check_cert_strength(SSL *ssl, Server_t *srv, int *choice)
|
||||||
{
|
{
|
||||||
/* print for first connection to server */
|
/* print for first connection to server */
|
||||||
const bool_t print_chain = srv->cert_status == CERT_STATUS_RECEIVING;
|
const bool print_chain = srv->cert_status == CERT_STATUS_RECEIVING;
|
||||||
bool_t success = TRUE;
|
bool success = true;
|
||||||
|
|
||||||
STACK_OF(X509) *sk = SSL_get_peer_cert_chain(ssl);
|
STACK_OF(X509) *sk = SSL_get_peer_cert_chain(ssl);
|
||||||
|
|
||||||
@ -507,14 +507,14 @@ static bool_t Tls_check_cert_strength(SSL *ssl, Server_t *srv, int *choice)
|
|||||||
if (print_chain)
|
if (print_chain)
|
||||||
MSG_WARN("In 2015, browsers have begun to deprecate SHA1 "
|
MSG_WARN("In 2015, browsers have begun to deprecate SHA1 "
|
||||||
"certificates.\n");
|
"certificates.\n");
|
||||||
} else if (!strncmp(buf, "md", 2) && success == TRUE) {
|
} else if (!strncmp(buf, "md", 2) && success == true) {
|
||||||
const char *msg = "A certificate in the chain uses the MD5 "
|
const char *msg = "A certificate in the chain uses the MD5 "
|
||||||
"signature algorithm, which is too weak "
|
"signature algorithm, which is too weak "
|
||||||
"to trust.";
|
"to trust.";
|
||||||
*choice = a_Dialog_choice("Flenser TLS security warning", msg,
|
*choice = a_Dialog_choice("Flenser TLS security warning", msg,
|
||||||
"Continue", "Cancel", NULL);
|
"Continue", "Cancel", NULL);
|
||||||
if (*choice != 1)
|
if (*choice != 1)
|
||||||
success = FALSE;
|
success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -574,7 +574,7 @@ static bool_t Tls_check_cert_strength(SSL *ssl, Server_t *srv, int *choice)
|
|||||||
If the pattern contain no wildcards, pattern_match(a, b) is
|
If the pattern contain no wildcards, pattern_match(a, b) is
|
||||||
equivalent to !strcasecmp(a, b). */
|
equivalent to !strcasecmp(a, b). */
|
||||||
|
|
||||||
static bool_t pattern_match (const char *pattern, const char *string)
|
static bool pattern_match (const char *pattern, const char *string)
|
||||||
{
|
{
|
||||||
|
|
||||||
const char *p = pattern, *n = string;
|
const char *p = pattern, *n = string;
|
||||||
@ -586,17 +586,17 @@ static bool_t pattern_match (const char *pattern, const char *string)
|
|||||||
;
|
;
|
||||||
for (; *n != '\0'; n++)
|
for (; *n != '\0'; n++)
|
||||||
if (tolower (*n) == c && pattern_match (p, n))
|
if (tolower (*n) == c && pattern_match (p, n))
|
||||||
return TRUE;
|
return true;
|
||||||
#ifdef ASTERISK_EXCLUDES_DOT
|
#ifdef ASTERISK_EXCLUDES_DOT
|
||||||
else if (*n == '.')
|
else if (*n == '.')
|
||||||
return FALSE;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
return c == '\0';
|
return c == '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (c != tolower (*n))
|
if (c != tolower (*n))
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return *n == '\0';
|
return *n == '\0';
|
||||||
}
|
}
|
||||||
@ -604,10 +604,10 @@ static bool_t pattern_match (const char *pattern, const char *string)
|
|||||||
/*
|
/*
|
||||||
* Check that the certificate corresponds to the site it's presented for.
|
* Check that the certificate corresponds to the site it's presented for.
|
||||||
*
|
*
|
||||||
* Return TRUE if the hostname matched or the user indicated acceptance.
|
* Return `true` if the hostname matched or the user indicated acceptance.
|
||||||
* FALSE on failure.
|
* `false` on failure.
|
||||||
*/
|
*/
|
||||||
static bool_t Tls_check_cert_hostname(X509 *cert, const char *host,
|
static bool Tls_check_cert_hostname(X509 *cert, const char *host,
|
||||||
int *choice)
|
int *choice)
|
||||||
{
|
{
|
||||||
if (cert == NULL || host == NULL)
|
if (cert == NULL || host == NULL)
|
||||||
@ -615,7 +615,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host,
|
|||||||
|
|
||||||
char *msg;
|
char *msg;
|
||||||
GENERAL_NAMES *subjectAltNames;
|
GENERAL_NAMES *subjectAltNames;
|
||||||
bool_t success = TRUE, alt_name_checked = FALSE;;
|
bool success = true, alt_name_checked = false;;
|
||||||
char common_name[256];
|
char common_name[256];
|
||||||
|
|
||||||
/* Check that HOST matches the common name in the certificate.
|
/* Check that HOST matches the common name in the certificate.
|
||||||
@ -657,7 +657,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host,
|
|||||||
/* Check for ipAddress */
|
/* Check for ipAddress */
|
||||||
/* TODO: Should we convert between IPv4-mapped IPv6
|
/* TODO: Should we convert between IPv4-mapped IPv6
|
||||||
* addresses and IPv4 addresses? */
|
* addresses and IPv4 addresses? */
|
||||||
alt_name_checked = TRUE;
|
alt_name_checked = true;
|
||||||
if (!ASN1_STRING_cmp (host_in_octet_string,
|
if (!ASN1_STRING_cmp (host_in_octet_string,
|
||||||
name->d.iPAddress))
|
name->d.iPAddress))
|
||||||
break;
|
break;
|
||||||
@ -671,7 +671,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host,
|
|||||||
unsigned char *name_in_utf8 = NULL;
|
unsigned char *name_in_utf8 = NULL;
|
||||||
|
|
||||||
/* Check for dNSName */
|
/* Check for dNSName */
|
||||||
alt_name_checked = TRUE;
|
alt_name_checked = true;
|
||||||
|
|
||||||
if (0 <= ASN1_STRING_to_UTF8 (&name_in_utf8, name->d.dNSName))
|
if (0 <= ASN1_STRING_to_UTF8 (&name_in_utf8, name->d.dNSName))
|
||||||
{
|
{
|
||||||
@ -693,15 +693,15 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host,
|
|||||||
if (host_in_octet_string)
|
if (host_in_octet_string)
|
||||||
ASN1_OCTET_STRING_free(host_in_octet_string);
|
ASN1_OCTET_STRING_free(host_in_octet_string);
|
||||||
|
|
||||||
if (alt_name_checked == TRUE && i >= numaltnames)
|
if (alt_name_checked == true && i >= numaltnames)
|
||||||
{
|
{
|
||||||
success = FALSE;
|
success = false;
|
||||||
*choice = a_Dialog_choice("Flenser TLS security warning",
|
*choice = a_Dialog_choice("Flenser TLS security warning",
|
||||||
err->str, "Continue", "Cancel", NULL);
|
err->str, "Continue", "Cancel", NULL);
|
||||||
|
|
||||||
switch (*choice){
|
switch (*choice){
|
||||||
case 1:
|
case 1:
|
||||||
success = TRUE;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
@ -712,7 +712,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host,
|
|||||||
dStr_free(err, 1);
|
dStr_free(err, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alt_name_checked == FALSE)
|
if (alt_name_checked == false)
|
||||||
{
|
{
|
||||||
/* Test commomName */
|
/* Test commomName */
|
||||||
X509_NAME *xname = X509_get_subject_name(cert);
|
X509_NAME *xname = X509_get_subject_name(cert);
|
||||||
@ -722,7 +722,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host,
|
|||||||
|
|
||||||
if (!pattern_match (common_name, host))
|
if (!pattern_match (common_name, host))
|
||||||
{
|
{
|
||||||
success = FALSE;
|
success = false;
|
||||||
msg = dStrconcat("Certificate common name ", common_name,
|
msg = dStrconcat("Certificate common name ", common_name,
|
||||||
" doesn't match requested host name ", host, NULL);
|
" doesn't match requested host name ", host, NULL);
|
||||||
*choice = a_Dialog_choice("Flenser TLS security warning",
|
*choice = a_Dialog_choice("Flenser TLS security warning",
|
||||||
@ -731,7 +731,7 @@ static bool_t Tls_check_cert_hostname(X509 *cert, const char *host,
|
|||||||
|
|
||||||
switch (*choice){
|
switch (*choice){
|
||||||
case 1:
|
case 1:
|
||||||
success = TRUE;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
@ -1106,7 +1106,7 @@ static void Tls_close_by_key(int connkey)
|
|||||||
static void Tls_connect(int fd, int connkey)
|
static void Tls_connect(int fd, int connkey)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
bool_t ongoing = FALSE, failed = TRUE;
|
bool ongoing = false, failed = true;
|
||||||
Conn_t *conn;
|
Conn_t *conn;
|
||||||
|
|
||||||
if (!(conn = reinterpret_cast< Conn_t * >( a_Klist_get_data(conn_list, connkey) ))) {
|
if (!(conn = reinterpret_cast< Conn_t * >( a_Klist_get_data(conn_list, connkey) ))) {
|
||||||
@ -1118,7 +1118,7 @@ static void Tls_connect(int fd, int connkey)
|
|||||||
MSG("Tls_connect: nested call to Tls_connect(), aborting\n");
|
MSG("Tls_connect: nested call to Tls_connect(), aborting\n");
|
||||||
abort();
|
abort();
|
||||||
} else {
|
} else {
|
||||||
conn->in_connect = TRUE;
|
conn->in_connect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ERR_peek_error()) {
|
if (ERR_peek_error()) {
|
||||||
@ -1143,14 +1143,14 @@ static void Tls_connect(int fd, int connkey)
|
|||||||
_MSG("iowatching fd %d for tls -- want %s\n", fd,
|
_MSG("iowatching fd %d for tls -- want %s\n", fd,
|
||||||
err1_ret == SSL_ERROR_WANT_READ ? "read" : "write");
|
err1_ret == SSL_ERROR_WANT_READ ? "read" : "write");
|
||||||
a_IOwatch_add_fd(fd, want, Tls_connect_cb, INT2VOIDP(connkey));
|
a_IOwatch_add_fd(fd, want, Tls_connect_cb, INT2VOIDP(connkey));
|
||||||
ongoing = TRUE;
|
ongoing = true;
|
||||||
failed = FALSE;
|
failed = false;
|
||||||
} else if (err1_ret == SSL_ERROR_SYSCALL || err1_ret == SSL_ERROR_SSL) {
|
} else if (err1_ret == SSL_ERROR_SYSCALL || err1_ret == SSL_ERROR_SSL) {
|
||||||
/* From the OpenSSL documentation: "Note that SSL_shutdown() must not
|
/* From the OpenSSL documentation: "Note that SSL_shutdown() must not
|
||||||
* be called if a previous fatal error has occurred on a connection
|
* be called if a previous fatal error has occurred on a connection
|
||||||
* i.e. if SSL_get_error() has returned SSL_ERROR_SYSCALL or
|
* i.e. if SSL_get_error() has returned SSL_ERROR_SYSCALL or
|
||||||
* SSL_ERROR_SSL." */
|
* SSL_ERROR_SSL." */
|
||||||
conn->do_shutdown = FALSE;
|
conn->do_shutdown = false;
|
||||||
|
|
||||||
unsigned long err2_ret = ERR_get_error();
|
unsigned long err2_ret = ERR_get_error();
|
||||||
|
|
||||||
@ -1199,7 +1199,7 @@ static void Tls_connect(int fd, int connkey)
|
|||||||
|
|
||||||
if (srv->cert_status == CERT_STATUS_USER_ACCEPTED ||
|
if (srv->cert_status == CERT_STATUS_USER_ACCEPTED ||
|
||||||
(Tls_examine_certificate(conn->ssl, srv) != -1)) {
|
(Tls_examine_certificate(conn->ssl, srv) != -1)) {
|
||||||
failed = FALSE;
|
failed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1210,22 +1210,22 @@ static void Tls_connect(int fd, int connkey)
|
|||||||
|
|
||||||
if (!ongoing) {
|
if (!ongoing) {
|
||||||
if (a_Klist_get_data(conn_list, connkey)) {
|
if (a_Klist_get_data(conn_list, connkey)) {
|
||||||
conn->connecting = FALSE;
|
conn->connecting = false;
|
||||||
if (failed) {
|
if (failed) {
|
||||||
conn->in_connect = FALSE;
|
conn->in_connect = false;
|
||||||
Tls_close_by_key(connkey);
|
Tls_close_by_key(connkey);
|
||||||
/* conn is freed now */
|
/* conn is freed now */
|
||||||
conn = NULL;
|
conn = NULL;
|
||||||
}
|
}
|
||||||
a_IOwatch_remove_fd(fd, DIO_READ|DIO_WRITE);
|
a_IOwatch_remove_fd(fd, DIO_READ|DIO_WRITE);
|
||||||
a_Http_connect_done(fd, failed ? FALSE : TRUE);
|
a_Http_connect_done(fd, not( failed ) );
|
||||||
} else {
|
} else {
|
||||||
MSG("Connection disappeared. Too long with a popup popped up?\n");
|
MSG("Connection disappeared. Too long with a popup popped up?\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn)
|
if (conn)
|
||||||
conn->in_connect = FALSE;
|
conn->in_connect = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Tls_connect_cb(int fd, void *vconnkey)
|
static void Tls_connect_cb(int fd, void *vconnkey)
|
||||||
@ -1239,14 +1239,14 @@ static void Tls_connect_cb(int fd, void *vconnkey)
|
|||||||
void a_Tls_openssl_connect(int fd, const DilloUrl *url)
|
void a_Tls_openssl_connect(int fd, const DilloUrl *url)
|
||||||
{
|
{
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
bool_t success = TRUE;
|
bool success = true;
|
||||||
int connkey = -1;
|
int connkey = -1;
|
||||||
|
|
||||||
if (!ssl_context)
|
if (!ssl_context)
|
||||||
success = FALSE;
|
success = false;
|
||||||
|
|
||||||
if (success && Tls_user_said_no(url)) {
|
if (success && Tls_user_said_no(url)) {
|
||||||
success = FALSE;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ERR_peek_error()) {
|
if (ERR_peek_error()) {
|
||||||
@ -1263,7 +1263,7 @@ void a_Tls_openssl_connect(int fd, const DilloUrl *url)
|
|||||||
do {
|
do {
|
||||||
MSG("SSL_new() failed: %s\n", ERR_error_string(err_ret, NULL));
|
MSG("SSL_new() failed: %s\n", ERR_error_string(err_ret, NULL));
|
||||||
} while ((err_ret = ERR_get_error()));
|
} while ((err_ret = ERR_get_error()));
|
||||||
success = FALSE;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* assign TLS connection to this file descriptor */
|
/* assign TLS connection to this file descriptor */
|
||||||
@ -1272,7 +1272,7 @@ void a_Tls_openssl_connect(int fd, const DilloUrl *url)
|
|||||||
do {
|
do {
|
||||||
MSG("SSL_set_fd() failed: %s\n", ERR_error_string(err_ret, NULL));
|
MSG("SSL_set_fd() failed: %s\n", ERR_error_string(err_ret, NULL));
|
||||||
} while ((err_ret = ERR_get_error()));
|
} while ((err_ret = ERR_get_error()));
|
||||||
success = FALSE;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
|
@ -313,7 +313,7 @@ void a_Bw_cancel_expect(BrowserWindow *bw)
|
|||||||
bw->nav_expect_url.reset();
|
bw->nav_expect_url.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t a_Bw_expecting(BrowserWindow *bw)
|
bool a_Bw_expecting(BrowserWindow *bw)
|
||||||
{
|
{
|
||||||
return (bw->nav_expect_url != nullptr);
|
return (bw->nav_expect_url != nullptr);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ void a_Bw_cleanup(BrowserWindow *bw);
|
|||||||
/* expect API */
|
/* expect API */
|
||||||
void a_Bw_expect(BrowserWindow *bw, const DilloUrl *Url);
|
void a_Bw_expect(BrowserWindow *bw, const DilloUrl *Url);
|
||||||
void a_Bw_cancel_expect(BrowserWindow *bw);
|
void a_Bw_cancel_expect(BrowserWindow *bw);
|
||||||
bool_t a_Bw_expecting(BrowserWindow *bw);
|
bool a_Bw_expecting(BrowserWindow *bw);
|
||||||
const DilloUrl *a_Bw_expected_url(BrowserWindow *bw);
|
const DilloUrl *a_Bw_expected_url(BrowserWindow *bw);
|
||||||
|
|
||||||
typedef void (*BwCallback_t)(BrowserWindow *bw, const void *data);
|
typedef void (*BwCallback_t)(BrowserWindow *bw, const void *data);
|
||||||
|
34
src/cache.cc
34
src/cache.cc
@ -661,7 +661,7 @@ static Dlist *Cache_parse_multiple_fields(const char *header,
|
|||||||
static void Cache_parse_header(CacheEntry_t *entry)
|
static void Cache_parse_header(CacheEntry_t *entry)
|
||||||
{
|
{
|
||||||
const char *header = entry->Header.c_str();
|
const char *header = entry->Header.c_str();
|
||||||
bool_t server1point0 = !strncmp(entry->Header.c_str(), "HTTP/1.0", 8);
|
bool server1point0 = !strncmp(entry->Header.c_str(), "HTTP/1.0", 8);
|
||||||
char *Length, *Type, *location_str, *encoding, *connection, *hsts;
|
char *Length, *Type, *location_str, *encoding, *connection, *hsts;
|
||||||
#ifndef DISABLE_COOKIES
|
#ifndef DISABLE_COOKIES
|
||||||
Dlist *Cookies;
|
Dlist *Cookies;
|
||||||
@ -894,17 +894,17 @@ static void Cache_finish_msg(CacheEntry_t *entry)
|
|||||||
* 'Op' is the operation to perform
|
* 'Op' is the operation to perform
|
||||||
* 'VPtr' is a (void) pointer to the IO control structure
|
* 'VPtr' is a (void) pointer to the IO control structure
|
||||||
*/
|
*/
|
||||||
bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
|
bool a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
|
||||||
const DilloUrl *Url)
|
const DilloUrl *Url)
|
||||||
{
|
{
|
||||||
int offset, len;
|
int offset, len;
|
||||||
const char *str;
|
const char *str;
|
||||||
Dstr *dstr1, *dstr2, *dstr3;
|
Dstr *dstr1, *dstr2, *dstr3;
|
||||||
bool_t done = FALSE;
|
bool done = false;
|
||||||
CacheEntry_t *entry = Cache_entry_search(Url);
|
CacheEntry_t *entry = Cache_entry_search(Url);
|
||||||
|
|
||||||
/* Assert a valid entry (not aborted) */
|
/* Assert a valid entry (not aborted) */
|
||||||
dReturn_val_if_fail (entry != NULL, FALSE);
|
dReturn_val_if_fail (entry != NULL, false);
|
||||||
|
|
||||||
_MSG("__a_Cache_process_dbuf__\n");
|
_MSG("__a_Cache_process_dbuf__\n");
|
||||||
|
|
||||||
@ -952,11 +952,11 @@ bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
|
|||||||
|
|
||||||
if ((entry->Flags & CA_GotLength) &&
|
if ((entry->Flags & CA_GotLength) &&
|
||||||
(entry->TransferSize >= entry->ExpectedSize)) {
|
(entry->TransferSize >= entry->ExpectedSize)) {
|
||||||
done = TRUE;
|
done = true;
|
||||||
}
|
}
|
||||||
if (!(entry->Flags & CA_KeepAlive)) {
|
if (!(entry->Flags & CA_KeepAlive)) {
|
||||||
/* Let IOClose finish it later */
|
/* Let IOClose finish it later */
|
||||||
done = FALSE;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = Cache_process_queue(entry);
|
entry = Cache_process_queue(entry);
|
||||||
@ -1178,10 +1178,10 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
|
|||||||
CacheClient_t *Client;
|
CacheClient_t *Client;
|
||||||
DilloWeb *ClientWeb;
|
DilloWeb *ClientWeb;
|
||||||
BrowserWindow *Client_bw = NULL;
|
BrowserWindow *Client_bw = NULL;
|
||||||
static bool_t Busy = FALSE;
|
static bool Busy = false;
|
||||||
bool_t AbortEntry = FALSE;
|
bool AbortEntry = false;
|
||||||
bool_t OfferDownload = FALSE;
|
bool OfferDownload = false;
|
||||||
bool_t TypeMismatch = FALSE;
|
bool TypeMismatch = false;
|
||||||
|
|
||||||
if (Busy)
|
if (Busy)
|
||||||
MSG_ERR("FATAL!: >>>> Cache_process_queue Caught busy!!! <<<<\n");
|
MSG_ERR("FATAL!: >>>> Cache_process_queue Caught busy!!! <<<<\n");
|
||||||
@ -1195,7 +1195,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
|
|||||||
if (a_Misc_content_type_check(entry->TypeHdr, Type) < 0) {
|
if (a_Misc_content_type_check(entry->TypeHdr, Type) < 0) {
|
||||||
MSG_HTTP("Content-Type '%s' doesn't match the real data.\n",
|
MSG_HTTP("Content-Type '%s' doesn't match the real data.\n",
|
||||||
entry->TypeHdr);
|
entry->TypeHdr);
|
||||||
TypeMismatch = TRUE;
|
TypeMismatch = true;
|
||||||
}
|
}
|
||||||
entry->TypeDet = dStrdup(Type);
|
entry->TypeDet = dStrdup(Type);
|
||||||
entry->Flags |= CA_GotContentType;
|
entry->Flags |= CA_GotContentType;
|
||||||
@ -1203,7 +1203,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
|
|||||||
return entry; /* i.e., wait for more data */
|
return entry; /* i.e., wait for more data */
|
||||||
}
|
}
|
||||||
|
|
||||||
Busy = TRUE;
|
Busy = true;
|
||||||
for (i = 0; (Client = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, i) )); ++i) {
|
for (i = 0; (Client = reinterpret_cast< CacheClient_t * >( dList_nth_data(ClientQueue, i) )); ++i) {
|
||||||
if (Client->Url == entry->Url.get()) {
|
if (Client->Url == entry->Url.get()) {
|
||||||
ClientWeb = reinterpret_cast< DilloWeb * >( Client->Web ); /* It was a (void*) */
|
ClientWeb = reinterpret_cast< DilloWeb * >( Client->Web ); /* It was a (void*) */
|
||||||
@ -1218,7 +1218,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
|
|||||||
if (TypeMismatch) {
|
if (TypeMismatch) {
|
||||||
a_UIcmd_set_msg(Client_bw,"HTTP warning: Content-Type '%s' "
|
a_UIcmd_set_msg(Client_bw,"HTTP warning: Content-Type '%s' "
|
||||||
"doesn't match the real data.", entry->TypeHdr);
|
"doesn't match the real data.", entry->TypeHdr);
|
||||||
OfferDownload = TRUE;
|
OfferDownload = true;
|
||||||
}
|
}
|
||||||
if (entry->Flags & CA_Redirect) {
|
if (entry->Flags & CA_Redirect) {
|
||||||
if (!Client->Callback) {
|
if (!Client->Callback) {
|
||||||
@ -1231,7 +1231,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
|
|||||||
if (entry->Flags & CA_HugeFile) {
|
if (entry->Flags & CA_HugeFile) {
|
||||||
a_UIcmd_set_msg(Client_bw, "Huge file! (%d MB)",
|
a_UIcmd_set_msg(Client_bw, "Huge file! (%d MB)",
|
||||||
entry->ExpectedSize / (1024*1024));
|
entry->ExpectedSize / (1024*1024));
|
||||||
AbortEntry = OfferDownload = TRUE;
|
AbortEntry = OfferDownload = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* For non root URLs, ignore redirections and 404 answers */
|
/* For non root URLs, ignore redirections and 404 answers */
|
||||||
@ -1247,7 +1247,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
|
|||||||
/* Not following redirection, so don't display page body. */
|
/* Not following redirection, so don't display page body. */
|
||||||
} else {
|
} else {
|
||||||
if (TypeMismatch) {
|
if (TypeMismatch) {
|
||||||
AbortEntry = TRUE;
|
AbortEntry = true;
|
||||||
} else {
|
} else {
|
||||||
const char *curr_type = Cache_current_content_type(entry);
|
const char *curr_type = Cache_current_content_type(entry);
|
||||||
st = a_Web_dispatch_by_type(curr_type, ClientWeb,
|
st = a_Web_dispatch_by_type(curr_type, ClientWeb,
|
||||||
@ -1258,7 +1258,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
|
|||||||
if (ClientWeb->flags & WEB_RootUrl) {
|
if (ClientWeb->flags & WEB_RootUrl) {
|
||||||
MSG("Content-Type '%s' not viewable.\n", curr_type);
|
MSG("Content-Type '%s' not viewable.\n", curr_type);
|
||||||
/* prepare a download offer... */
|
/* prepare a download offer... */
|
||||||
AbortEntry = OfferDownload = TRUE;
|
AbortEntry = OfferDownload = true;
|
||||||
} else {
|
} else {
|
||||||
/* TODO: Resource Type not handled.
|
/* TODO: Resource Type not handled.
|
||||||
* Not aborted to avoid multiple connections on the
|
* Not aborted to avoid multiple connections on the
|
||||||
@ -1347,7 +1347,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
|
|||||||
a_Dicache_cleanup();
|
a_Dicache_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
Busy = FALSE;
|
Busy = false;
|
||||||
_MSG("QueueSize ====> %d\n", dList_length(ClientQueue));
|
_MSG("QueueSize ====> %d\n", dList_length(ClientQueue));
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
|
|||||||
const char *from);
|
const char *from);
|
||||||
uint_t a_Cache_get_flags(const DilloUrl *url);
|
uint_t a_Cache_get_flags(const DilloUrl *url);
|
||||||
uint_t a_Cache_get_flags_with_redirection(const DilloUrl *url);
|
uint_t a_Cache_get_flags_with_redirection(const DilloUrl *url);
|
||||||
bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
|
bool a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size,
|
||||||
const DilloUrl *Url);
|
const DilloUrl *Url);
|
||||||
int a_Cache_download_enabled(const DilloUrl *url);
|
int a_Cache_download_enabled(const DilloUrl *url);
|
||||||
void a_Cache_entry_remove_by_url(DilloUrl *url);
|
void a_Cache_entry_remove_by_url(DilloUrl *url);
|
||||||
|
12
src/capi.cc
12
src/capi.cc
@ -346,13 +346,13 @@ static void Capi_dpi_send_source(BrowserWindow *bw, DilloUrl *url)
|
|||||||
/**
|
/**
|
||||||
* Shall we permit this request to open a URL?
|
* Shall we permit this request to open a URL?
|
||||||
*/
|
*/
|
||||||
static bool_t Capi_request_permitted(DilloWeb *web)
|
static bool Capi_request_permitted(DilloWeb *web)
|
||||||
{
|
{
|
||||||
bool_t permit = FALSE;
|
bool permit = false;
|
||||||
|
|
||||||
/* web->requester is NULL if the action is initiated by user */
|
/* web->requester is NULL if the action is initiated by user */
|
||||||
if (!web->requester)
|
if (!web->requester)
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
if (web->flags & ~WEB_RootUrl &&
|
if (web->flags & ~WEB_RootUrl &&
|
||||||
!dStrAsciiCasecmp(URL_SCHEME(web->requester), "https")) {
|
!dStrAsciiCasecmp(URL_SCHEME(web->requester), "https")) {
|
||||||
@ -372,13 +372,13 @@ static bool_t Capi_request_permitted(DilloWeb *web)
|
|||||||
if (dStrAsciiCasecmp(s, "https") && dStrAsciiCasecmp(s, "data")) {
|
if (dStrAsciiCasecmp(s, "https") && dStrAsciiCasecmp(s, "data")) {
|
||||||
MSG("capi: Blocked mixed content: %s -> %s\n",
|
MSG("capi: Blocked mixed content: %s -> %s\n",
|
||||||
URL_STR(web->requester.get()), URL_STR(web->url.get()));
|
URL_STR(web->requester.get()), URL_STR(web->url.get()));
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a_Capi_get_flags(web->url.get()) & CAPI_IsCached ||
|
if (a_Capi_get_flags(web->url.get()) & CAPI_IsCached ||
|
||||||
a_Domain_permit(web->requester.get(), web->url.get())) {
|
a_Domain_permit(web->requester.get(), web->url.get())) {
|
||||||
permit = TRUE;
|
permit = true;
|
||||||
}
|
}
|
||||||
return permit;
|
return permit;
|
||||||
}
|
}
|
||||||
@ -771,7 +771,7 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info,
|
|||||||
if (strcmp(reinterpret_cast< const char * >( Data2 ), "send_page_2eof") == 0) {
|
if (strcmp(reinterpret_cast< const char * >( Data2 ), "send_page_2eof") == 0) {
|
||||||
/* Data1 = dbuf */
|
/* Data1 = dbuf */
|
||||||
DataBuf *dbuf = reinterpret_cast< DataBuf * >( Data1 );
|
DataBuf *dbuf = reinterpret_cast< DataBuf * >( Data1 );
|
||||||
bool_t finished = a_Cache_process_dbuf(IORead, dbuf->Buf,
|
bool finished = a_Cache_process_dbuf(IORead, dbuf->Buf,
|
||||||
dbuf->Size, conn->url);
|
dbuf->Size, conn->url);
|
||||||
if (finished && Capi_conn_valid(conn) && conn->InfoRecv) {
|
if (finished && Capi_conn_valid(conn) && conn->InfoRecv) {
|
||||||
/* If we have a persistent connection where cache tells us
|
/* If we have a persistent connection where cache tells us
|
||||||
|
@ -66,7 +66,7 @@ static int num_ccontrol = 0;
|
|||||||
static int num_ccontrol_max = 1;
|
static int num_ccontrol_max = 1;
|
||||||
static CookieControlAction default_action = COOKIE_DENY;
|
static CookieControlAction default_action = COOKIE_DENY;
|
||||||
|
|
||||||
static bool_t disabled;
|
static bool disabled;
|
||||||
|
|
||||||
static FILE *Cookies_fopen(const char *file, char *init_str);
|
static FILE *Cookies_fopen(const char *file, char *init_str);
|
||||||
static CookieControlAction Cookies_control_check(const DilloUrl *url);
|
static CookieControlAction Cookies_control_check(const DilloUrl *url);
|
||||||
@ -117,7 +117,7 @@ static FILE *Cookies_fopen(const char *filename, char *init_str)
|
|||||||
void a_Cookies_init(void)
|
void a_Cookies_init(void)
|
||||||
{
|
{
|
||||||
/* Default setting */
|
/* Default setting */
|
||||||
disabled = TRUE;
|
disabled = true;
|
||||||
|
|
||||||
/* Read and parse the cookie control file (cookiesrc) */
|
/* Read and parse the cookie control file (cookiesrc) */
|
||||||
if (Cookie_control_init() != 0) {
|
if (Cookie_control_init() != 0) {
|
||||||
@ -126,7 +126,7 @@ void a_Cookies_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MSG("Enabling cookies as from cookiesrc...\n");
|
MSG("Enabling cookies as from cookiesrc...\n");
|
||||||
disabled = FALSE;
|
disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,7 +246,7 @@ static int Cookie_control_init(void)
|
|||||||
char line[LINE_MAXLEN];
|
char line[LINE_MAXLEN];
|
||||||
char domain[LINE_MAXLEN];
|
char domain[LINE_MAXLEN];
|
||||||
char rule[LINE_MAXLEN];
|
char rule[LINE_MAXLEN];
|
||||||
bool_t enabled = FALSE;
|
bool enabled = false;
|
||||||
|
|
||||||
/* Get a file pointer */
|
/* Get a file pointer */
|
||||||
filename = dStrconcat(dGethomedir(), "/.flenser/cookiesrc", NULL);
|
filename = dStrconcat(dGethomedir(), "/.flenser/cookiesrc", NULL);
|
||||||
@ -320,13 +320,13 @@ static int Cookie_control_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cc.action != COOKIE_DENY)
|
if (cc.action != COOKIE_DENY)
|
||||||
enabled = TRUE;
|
enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
|
|
||||||
return (enabled ? 0 : 1);
|
return not( enabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +82,7 @@ Dstr *a_Decode_transfer_process(DecodeTransfer *dc, const char *instr,
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t a_Decode_transfer_finished(DecodeTransfer *dc)
|
bool a_Decode_transfer_finished(DecodeTransfer *dc)
|
||||||
{
|
{
|
||||||
return dc->finished;
|
return dc->finished;
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ struct Decode {
|
|||||||
struct DecodeTransfer {
|
struct DecodeTransfer {
|
||||||
Dstr *leftover;
|
Dstr *leftover;
|
||||||
void *state;
|
void *state;
|
||||||
bool_t finished; /**< has the terminating chunk been seen? */
|
bool finished; /**< has the terminating chunk been seen? */
|
||||||
};
|
};
|
||||||
|
|
||||||
DecodeTransfer *a_Decode_transfer_init(const char *format);
|
DecodeTransfer *a_Decode_transfer_init(const char *format);
|
||||||
Dstr *a_Decode_transfer_process(DecodeTransfer *dc, const char *instr,
|
Dstr *a_Decode_transfer_process(DecodeTransfer *dc, const char *instr,
|
||||||
int inlen);
|
int inlen);
|
||||||
bool_t a_Decode_transfer_finished(DecodeTransfer *dc);
|
bool a_Decode_transfer_finished(DecodeTransfer *dc);
|
||||||
void a_Decode_transfer_free(DecodeTransfer *dc);
|
void a_Decode_transfer_free(DecodeTransfer *dc);
|
||||||
|
|
||||||
Decode *a_Decode_content_init(const char *format);
|
Decode *a_Decode_content_init(const char *format);
|
||||||
|
@ -24,7 +24,7 @@ struct Rule {
|
|||||||
|
|
||||||
std::vector< Rule > exceptions;
|
std::vector< Rule > exceptions;
|
||||||
|
|
||||||
static bool_t default_deny = FALSE;
|
static bool default_deny = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse domainrc.
|
* Parse domainrc.
|
||||||
@ -56,10 +56,10 @@ void a_Domain_parse(FILE *fp)
|
|||||||
} else {
|
} else {
|
||||||
if (dStrAsciiCasecmp(tok1, "default") == 0) {
|
if (dStrAsciiCasecmp(tok1, "default") == 0) {
|
||||||
if (dStrAsciiCasecmp(tok2, "deny") == 0) {
|
if (dStrAsciiCasecmp(tok2, "deny") == 0) {
|
||||||
default_deny = TRUE;
|
default_deny = true;
|
||||||
MSG("Domain: Default deny.\n");
|
MSG("Domain: Default deny.\n");
|
||||||
} else if (dStrAsciiCasecmp(tok2, "accept") == 0) {
|
} else if (dStrAsciiCasecmp(tok2, "accept") == 0) {
|
||||||
default_deny = FALSE;
|
default_deny = false;
|
||||||
MSG("Domain: Default accept.\n");
|
MSG("Domain: Default accept.\n");
|
||||||
} else {
|
} else {
|
||||||
MSG("Domain: Default action \"%s\" not recognised.\n", tok2);
|
MSG("Domain: Default action \"%s\" not recognised.\n", tok2);
|
||||||
@ -84,7 +84,7 @@ void a_Domain_freeall(void)
|
|||||||
* "example.org" pattern matches "example.org".
|
* "example.org" pattern matches "example.org".
|
||||||
* ".example.org" pattern matches "example.org" and "sub.example.org".
|
* ".example.org" pattern matches "example.org" and "sub.example.org".
|
||||||
*/
|
*/
|
||||||
static bool_t Domain_match(const char *host, const char *pattern) {
|
static bool Domain_match(const char *host, const char *pattern) {
|
||||||
int cmp = strcmp(pattern, "*");
|
int cmp = strcmp(pattern, "*");
|
||||||
|
|
||||||
if (cmp) {
|
if (cmp) {
|
||||||
@ -99,20 +99,20 @@ static bool_t Domain_match(const char *host, const char *pattern) {
|
|||||||
cmp = dStrAsciiCasecmp(host + diff, pattern);
|
cmp = dStrAsciiCasecmp(host + diff, pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmp ? FALSE : TRUE;
|
return not( cmp );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the resource at 'source' permitted to request the resource at 'dest'?
|
* Is the resource at 'source' permitted to request the resource at 'dest'?
|
||||||
*/
|
*/
|
||||||
bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
|
bool a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bool_t ret;
|
bool ret;
|
||||||
const char *source_host, *dest_host;
|
const char *source_host, *dest_host;
|
||||||
|
|
||||||
if (default_deny == FALSE && exceptions.size() == 0)
|
if (default_deny == false && exceptions.size() == 0)
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
source_host = URL_HOST(source);
|
source_host = URL_HOST(source);
|
||||||
dest_host = URL_HOST(dest);
|
dest_host = URL_HOST(dest);
|
||||||
@ -120,15 +120,15 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
|
|||||||
if (dest_host[0] == '\0') {
|
if (dest_host[0] == '\0') {
|
||||||
ret = source_host[0] == '\0' ||
|
ret = source_host[0] == '\0' ||
|
||||||
!dStrAsciiCasecmp(URL_SCHEME(dest), "data");
|
!dStrAsciiCasecmp(URL_SCHEME(dest), "data");
|
||||||
if (ret == FALSE)
|
if (ret == false)
|
||||||
MSG("Domain: DENIED %s -> %s.\n", source_host, URL_STR(dest));
|
MSG("Domain: DENIED %s -> %s.\n", source_host, URL_STR(dest));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a_Url_same_organization(*source, *dest))
|
if (a_Url_same_organization(*source, *dest))
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
ret = default_deny ? FALSE : TRUE;
|
ret = not( default_deny );
|
||||||
|
|
||||||
for (i = 0; i < exceptions.size(); i++) {
|
for (i = 0; i < exceptions.size(); i++) {
|
||||||
if (Domain_match(source_host, exceptions[i].origin.c_str()) &&
|
if (Domain_match(source_host, exceptions[i].origin.c_str()) &&
|
||||||
@ -140,7 +140,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == FALSE) {
|
if (ret == false) {
|
||||||
const char *src = source_host[0] ? source_host : URL_STR(source);
|
const char *src = source_host[0] ? source_host : URL_STR(source);
|
||||||
|
|
||||||
MSG("Domain: DENIED %s -> %s.\n", src, dest_host);
|
MSG("Domain: DENIED %s -> %s.\n", src, dest_host);
|
||||||
|
@ -10,7 +10,7 @@ extern "C" {
|
|||||||
|
|
||||||
void a_Domain_parse(FILE *fp);
|
void a_Domain_parse(FILE *fp);
|
||||||
void a_Domain_freeall(void);
|
void a_Domain_freeall(void);
|
||||||
bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest);
|
bool a_Domain_permit(const DilloUrl *source, const DilloUrl *dest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
16
src/hsts.cc
16
src/hsts.cc
@ -42,7 +42,7 @@
|
|||||||
struct HstsData_t {
|
struct HstsData_t {
|
||||||
std::string host;
|
std::string host;
|
||||||
time_t expires_at;
|
time_t expires_at;
|
||||||
bool_t subdomains;
|
bool subdomains;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* When there is difficulty in representing future dates, use the (by far)
|
/* When there is difficulty in representing future dates, use the (by far)
|
||||||
@ -103,7 +103,7 @@ static time_t Hsts_future_time(long seconds_from_now)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Hsts_set_policy(const char *host, long max_age, bool_t subdomains)
|
static void Hsts_set_policy(const char *host, long max_age, bool subdomains)
|
||||||
{
|
{
|
||||||
time_t exp = Hsts_future_time(max_age);
|
time_t exp = Hsts_future_time(max_age);
|
||||||
HstsData_t *policy = Hsts_get_policy(host);
|
HstsData_t *policy = Hsts_get_policy(host);
|
||||||
@ -186,7 +186,7 @@ void a_Hsts_set(const char *header, const DilloUrl *url)
|
|||||||
{
|
{
|
||||||
long max_age = 0;
|
long max_age = 0;
|
||||||
const char *host = URL_HOST(url);
|
const char *host = URL_HOST(url);
|
||||||
bool_t max_age_valid = FALSE, subdomains = FALSE;
|
bool max_age_valid = false, subdomains = false;
|
||||||
|
|
||||||
_MSG("HSTS header for %s: %s\n", host, header);
|
_MSG("HSTS header for %s: %s\n", host, header);
|
||||||
|
|
||||||
@ -239,10 +239,10 @@ void a_Hsts_set(const char *header, const DilloUrl *url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t Hsts_expired(HstsData_t *policy)
|
static bool Hsts_expired(HstsData_t *policy)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(nullptr);
|
||||||
bool_t ret = (now > policy->expires_at) ? TRUE : FALSE;
|
bool ret = not( now > policy->expires_at );
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
_MSG("HSTS: expired\n");
|
_MSG("HSTS: expired\n");
|
||||||
@ -250,9 +250,9 @@ static bool_t Hsts_expired(HstsData_t *policy)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t a_Hsts_require_https(const char *host)
|
bool a_Hsts_require_https(const char *host)
|
||||||
{
|
{
|
||||||
bool_t ret = FALSE;
|
bool ret = false;
|
||||||
|
|
||||||
if (host) {
|
if (host) {
|
||||||
HstsData_t *policy = Hsts_get_policy(host);
|
HstsData_t *policy = Hsts_get_policy(host);
|
||||||
|
@ -10,7 +10,7 @@ extern "C" {
|
|||||||
|
|
||||||
void a_Hsts_init(FILE *fp);
|
void a_Hsts_init(FILE *fp);
|
||||||
void a_Hsts_set(const char *header, const DilloUrl *url);
|
void a_Hsts_set(const char *header, const DilloUrl *url);
|
||||||
bool_t a_Hsts_require_https(const char *host);
|
bool a_Hsts_require_https(const char *host);
|
||||||
void a_Hsts_freeall( void );
|
void a_Hsts_freeall( void );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
18
src/html.cc
18
src/html.cc
@ -288,7 +288,7 @@ void a_Html_form_reset(void *v_html, void *v_form)
|
|||||||
/**
|
/**
|
||||||
* Used by the "Show/Hide hiddens" form menuitem.
|
* Used by the "Show/Hide hiddens" form menuitem.
|
||||||
*/
|
*/
|
||||||
void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display)
|
void a_Html_form_display_hiddens(void *v_html, void *v_form, bool display)
|
||||||
{
|
{
|
||||||
DilloHtml *html = (DilloHtml*)v_html;
|
DilloHtml *html = (DilloHtml*)v_html;
|
||||||
|
|
||||||
@ -640,7 +640,7 @@ DilloHtmlForm *DilloHtml::getCurrentForm ()
|
|||||||
return forms.back().get();
|
return forms.back().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t DilloHtml::unloadedImages()
|
bool DilloHtml::unloadedImages()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < images.size(); i++) {
|
for (int i = 0; i < images.size(); i++) {
|
||||||
if (images.at(i)->image != NULL) {
|
if (images.at(i)->image != NULL) {
|
||||||
@ -722,7 +722,7 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img,
|
|||||||
// image menu
|
// image menu
|
||||||
if (link != -1)
|
if (link != -1)
|
||||||
linkurl = html->links.at(link).get();
|
linkurl = html->links.at(link).get();
|
||||||
const bool_t loaded_img = (html->images.at(img)->image == NULL);
|
const bool loaded_img = (html->images.at(img)->image == NULL);
|
||||||
a_UIcmd_image_popup(bw, html->images.at(img)->url.get(), loaded_img,
|
a_UIcmd_image_popup(bw, html->images.at(img)->url.get(), loaded_img,
|
||||||
html->page_url.get(), linkurl);
|
html->page_url.get(), linkurl);
|
||||||
ret = true;
|
ret = true;
|
||||||
@ -825,7 +825,7 @@ static int Html_ms_stupid_quotes_2ucs(int codepoint)
|
|||||||
* The "&#" has already been consumed.
|
* The "&#" has already been consumed.
|
||||||
*/
|
*/
|
||||||
static const char *Html_parse_numeric_charref(DilloHtml *html, char *tok,
|
static const char *Html_parse_numeric_charref(DilloHtml *html, char *tok,
|
||||||
bool_t is_attr, int *entsize)
|
bool is_attr, int *entsize)
|
||||||
{
|
{
|
||||||
static char buf[5];
|
static char buf[5];
|
||||||
char *s = tok;
|
char *s = tok;
|
||||||
@ -928,7 +928,7 @@ static Charref_t *Html_charref_search(char *key)
|
|||||||
* The "&" has already been consumed.
|
* The "&" has already been consumed.
|
||||||
*/
|
*/
|
||||||
static const char *Html_parse_named_charref(DilloHtml *html, char *tok,
|
static const char *Html_parse_named_charref(DilloHtml *html, char *tok,
|
||||||
bool_t is_attr, int *entsize)
|
bool is_attr, int *entsize)
|
||||||
{
|
{
|
||||||
Charref_t *p;
|
Charref_t *p;
|
||||||
char c;
|
char c;
|
||||||
@ -984,7 +984,7 @@ static const char *Html_parse_named_charref(DilloHtml *html, char *tok,
|
|||||||
* For valid entities, *entsize is set to the length of the parsed entity.
|
* For valid entities, *entsize is set to the length of the parsed entity.
|
||||||
*/
|
*/
|
||||||
static const char *Html_parse_entity(DilloHtml *html, const char *token,
|
static const char *Html_parse_entity(DilloHtml *html, const char *token,
|
||||||
int toksize, int *entsize, bool_t is_attr)
|
int toksize, int *entsize, bool is_attr)
|
||||||
{
|
{
|
||||||
const char *ret = NULL;
|
const char *ret = NULL;
|
||||||
|
|
||||||
@ -1034,7 +1034,7 @@ a_Html_parse_entities(DilloHtml *html, const char *token, int toksize)
|
|||||||
|
|
||||||
for (i = s; i < toksize; i++) {
|
for (i = s; i < toksize; i++) {
|
||||||
const char *entstr;
|
const char *entstr;
|
||||||
const bool_t is_attr = FALSE;
|
const bool is_attr = false;
|
||||||
|
|
||||||
if (token[i] == '&' &&
|
if (token[i] == '&' &&
|
||||||
(entstr = Html_parse_entity(html, token+i, toksize-i, &entsize,
|
(entstr = Html_parse_entity(html, token+i, toksize-i, &entsize,
|
||||||
@ -3257,7 +3257,7 @@ static void Html_tag_open_base(DilloHtml *html, const char *tag, int tagsize)
|
|||||||
|
|
||||||
if (html->InFlags & IN_HEAD) {
|
if (html->InFlags & IN_HEAD) {
|
||||||
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "href"))) {
|
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "href"))) {
|
||||||
bool_t html5 = html->DocType == DT_HTML &&
|
bool html5 = html->DocType == DT_HTML &&
|
||||||
html->DocTypeVersion >= 5.0f;
|
html->DocTypeVersion >= 5.0f;
|
||||||
|
|
||||||
BaseUrl = html5 ? a_Html_url_new(html, attrbuf, NULL, 0) :
|
BaseUrl = html5 ? a_Html_url_new(html, attrbuf, NULL, 0) :
|
||||||
@ -4129,7 +4129,7 @@ static const char *Html_get_attr2(DilloHtml *html,
|
|||||||
} else if (tag[i] == '&' &&
|
} else if (tag[i] == '&' &&
|
||||||
(tag_parsing_flags & HTML_ParseEntities)) {
|
(tag_parsing_flags & HTML_ParseEntities)) {
|
||||||
const char *entstr;
|
const char *entstr;
|
||||||
const bool_t is_attr = TRUE;
|
const bool is_attr = true;
|
||||||
|
|
||||||
if ((entstr = Html_parse_entity(html, tag+i, tagsize-i, &entsize,
|
if ((entstr = Html_parse_entity(html, tag+i, tagsize-i, &entsize,
|
||||||
is_attr))) {
|
is_attr))) {
|
||||||
|
@ -29,7 +29,7 @@ extern "C" {
|
|||||||
void a_Html_load_images(void *v_html, DilloUrl *pattern);
|
void a_Html_load_images(void *v_html, DilloUrl *pattern);
|
||||||
void a_Html_form_submit(void *v_html, void *v_form);
|
void a_Html_form_submit(void *v_html, void *v_form);
|
||||||
void a_Html_form_reset(void *v_html, void *v_form);
|
void a_Html_form_reset(void *v_html, void *v_form);
|
||||||
void a_Html_form_display_hiddens(void *v_html, void *v_form, bool_t display);
|
void a_Html_form_display_hiddens(void *v_html, void *v_form, bool display);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ public:
|
|||||||
int formNew(DilloHtmlMethod method, const DilloUrl *action,
|
int formNew(DilloHtmlMethod method, const DilloUrl *action,
|
||||||
DilloHtmlEnc enc, const char *charset);
|
DilloHtmlEnc enc, const char *charset);
|
||||||
DilloHtmlForm *getCurrentForm ();
|
DilloHtmlForm *getCurrentForm ();
|
||||||
bool_t unloadedImages();
|
bool unloadedImages();
|
||||||
void loadImages (const DilloUrl *pattern);
|
void loadImages (const DilloUrl *pattern);
|
||||||
void addCssUrl(const DilloUrl *url);
|
void addCssUrl(const DilloUrl *url);
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ static void Menu_popup_cb(void *data)
|
|||||||
* Page popup menu (construction & popup)
|
* Page popup menu (construction & popup)
|
||||||
*/
|
*/
|
||||||
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls)
|
bool has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls)
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *p
|
|||||||
* Image popup menu (construction & popup)
|
* Image popup menu (construction & popup)
|
||||||
*/
|
*/
|
||||||
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
bool_t loaded_img, DilloUrl *page_url,
|
bool loaded_img, DilloUrl *page_url,
|
||||||
DilloUrl *link_url)
|
DilloUrl *link_url)
|
||||||
{
|
{
|
||||||
static DilloUrl *popup_page_url = NULL;
|
static DilloUrl *popup_page_url = NULL;
|
||||||
@ -622,7 +622,7 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
|
|||||||
* Form popup menu (construction & popup)
|
* Form popup menu (construction & popup)
|
||||||
*/
|
*/
|
||||||
void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
|
void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
|
||||||
void *formptr, bool_t hidvis)
|
void *formptr, bool hidvis)
|
||||||
{
|
{
|
||||||
static bool hiddens_visible;
|
static bool hiddens_visible;
|
||||||
static Fl_Menu_Item pm[] = {
|
static Fl_Menu_Item pm[] = {
|
||||||
|
@ -8,14 +8,14 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls);
|
bool has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls);
|
||||||
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
const DilloUrl *page_url);
|
const DilloUrl *page_url);
|
||||||
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
bool_t loaded_img, DilloUrl *page_url,
|
bool loaded_img, DilloUrl *page_url,
|
||||||
DilloUrl *link_url);
|
DilloUrl *link_url);
|
||||||
void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
|
void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
|
||||||
void *vform, bool_t showing_hiddens);
|
void *vform, bool showing_hiddens);
|
||||||
void a_Menu_file_popup(BrowserWindow *bw, void *v_wid);
|
void a_Menu_file_popup(BrowserWindow *bw, void *v_wid);
|
||||||
void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url);
|
void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url);
|
||||||
void a_Menu_history_popup(BrowserWindow *bw, int x, int y, int direction);
|
void a_Menu_history_popup(BrowserWindow *bw, int x, int y, int direction);
|
||||||
|
@ -184,7 +184,7 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url,
|
|||||||
const DilloUrl *requester, int offset)
|
const DilloUrl *requester, int offset)
|
||||||
{
|
{
|
||||||
const DilloUrl *old_url;
|
const DilloUrl *old_url;
|
||||||
bool_t MustLoad, ForceReload, IgnoreScroll;
|
bool MustLoad, ForceReload, IgnoreScroll;
|
||||||
int x, y, idx, ClientKey;
|
int x, y, idx, ClientKey;
|
||||||
DilloWeb *Web;
|
DilloWeb *Web;
|
||||||
|
|
||||||
@ -261,7 +261,8 @@ void a_Nav_cancel_expect_if_eq(BrowserWindow *bw, const DilloUrl *url)
|
|||||||
*/
|
*/
|
||||||
void a_Nav_expect_done(BrowserWindow *bw)
|
void a_Nav_expect_done(BrowserWindow *bw)
|
||||||
{
|
{
|
||||||
int m, url_idx, posx, posy, reload, repush, e2equery, goto_old_scroll=TRUE;
|
int m, url_idx, posx, posy, reload, repush, e2equery;
|
||||||
|
bool goto_old_scroll= true;
|
||||||
std::optional< std::string > fragment;
|
std::optional< std::string > fragment;
|
||||||
|
|
||||||
dReturn_if_fail(bw != NULL);
|
dReturn_if_fail(bw != NULL);
|
||||||
@ -292,11 +293,11 @@ void a_Nav_expect_done(BrowserWindow *bw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fragment) {
|
if (fragment) {
|
||||||
goto_old_scroll = FALSE;
|
goto_old_scroll = false;
|
||||||
if (repush) {
|
if (repush) {
|
||||||
Nav_get_scroll_pos(bw, &posx, &posy);
|
Nav_get_scroll_pos(bw, &posx, &posy);
|
||||||
if (posx || posy)
|
if (posx || posy)
|
||||||
goto_old_scroll = TRUE;
|
goto_old_scroll = true;
|
||||||
} else if (e2equery) {
|
} else if (e2equery) {
|
||||||
/* Reset scroll, so repush goes to fragment in the next pass */
|
/* Reset scroll, so repush goes to fragment in the next pass */
|
||||||
Nav_save_scroll_pos(bw, a_Nav_stack_ptr(bw), 0, 0);
|
Nav_save_scroll_pos(bw, a_Nav_stack_ptr(bw), 0, 0);
|
||||||
|
86
src/prefs.hh
86
src/prefs.hh
@ -51,7 +51,7 @@ typedef struct {
|
|||||||
DilloUrl *start_page;
|
DilloUrl *start_page;
|
||||||
DilloUrl *home;
|
DilloUrl *home;
|
||||||
DilloUrl *new_tab_page;
|
DilloUrl *new_tab_page;
|
||||||
bool_t allow_white_bg;
|
bool allow_white_bg;
|
||||||
int32_t white_bg_replacement;
|
int32_t white_bg_replacement;
|
||||||
int32_t bg_color;
|
int32_t bg_color;
|
||||||
int32_t ui_button_highlight_color;
|
int32_t ui_button_highlight_color;
|
||||||
@ -64,65 +64,65 @@ typedef struct {
|
|||||||
int32_t ui_tab_fg_color;
|
int32_t ui_tab_fg_color;
|
||||||
int32_t ui_tab_height;
|
int32_t ui_tab_height;
|
||||||
int32_t ui_text_bg_color;
|
int32_t ui_text_bg_color;
|
||||||
bool_t contrast_visited_color;
|
bool contrast_visited_color;
|
||||||
bool_t show_tooltip;
|
bool show_tooltip;
|
||||||
bool_t show_ui_tooltip;
|
bool show_ui_tooltip;
|
||||||
char *theme;
|
char *theme;
|
||||||
int panel_size;
|
int panel_size;
|
||||||
bool_t small_icons;
|
bool small_icons;
|
||||||
bool_t limit_text_width;
|
bool limit_text_width;
|
||||||
bool_t adjust_min_width;
|
bool adjust_min_width;
|
||||||
bool_t adjust_table_min_width;
|
bool adjust_table_min_width;
|
||||||
bool_t focus_new_tab;
|
bool focus_new_tab;
|
||||||
double font_factor;
|
double font_factor;
|
||||||
double zoom_factor;
|
double zoom_factor;
|
||||||
int32_t font_max_size;
|
int32_t font_max_size;
|
||||||
int32_t font_min_size;
|
int32_t font_min_size;
|
||||||
int32_t scroll_step;
|
int32_t scroll_step;
|
||||||
int32_t scroll_page_overlap;
|
int32_t scroll_page_overlap;
|
||||||
bool_t scrollbar_on_left;
|
bool scrollbar_on_left;
|
||||||
bool_t scrollbar_page_mode;
|
bool scrollbar_page_mode;
|
||||||
bool_t show_back;
|
bool show_back;
|
||||||
bool_t show_forw;
|
bool show_forw;
|
||||||
bool_t show_home;
|
bool show_home;
|
||||||
bool_t show_reload;
|
bool show_reload;
|
||||||
bool_t show_save;
|
bool show_save;
|
||||||
bool_t show_stop;
|
bool show_stop;
|
||||||
bool_t show_bookmarks;
|
bool show_bookmarks;
|
||||||
bool_t show_tools;
|
bool show_tools;
|
||||||
bool_t show_filemenu;
|
bool show_filemenu;
|
||||||
bool_t show_clear_url;
|
bool show_clear_url;
|
||||||
bool_t show_url;
|
bool show_url;
|
||||||
bool_t show_search;
|
bool show_search;
|
||||||
bool_t show_help;
|
bool show_help;
|
||||||
bool_t show_progress_box;
|
bool show_progress_box;
|
||||||
bool_t show_quit_dialog;
|
bool show_quit_dialog;
|
||||||
bool_t fullwindow_start;
|
bool fullwindow_start;
|
||||||
bool_t load_images;
|
bool load_images;
|
||||||
char *ignore_image_formats;
|
char *ignore_image_formats;
|
||||||
bool_t load_background_images;
|
bool load_background_images;
|
||||||
bool_t load_stylesheets;
|
bool load_stylesheets;
|
||||||
bool_t parse_embedded_css;
|
bool parse_embedded_css;
|
||||||
bool_t http_persistent_conns;
|
bool http_persistent_conns;
|
||||||
bool_t http_strict_transport_security;
|
bool http_strict_transport_security;
|
||||||
bool_t http_force_https;
|
bool http_force_https;
|
||||||
int32_t buffered_drawing;
|
int32_t buffered_drawing;
|
||||||
char *font_serif;
|
char *font_serif;
|
||||||
char *font_sans_serif;
|
char *font_sans_serif;
|
||||||
char *font_cursive;
|
char *font_cursive;
|
||||||
char *font_fantasy;
|
char *font_fantasy;
|
||||||
char *font_monospace;
|
char *font_monospace;
|
||||||
bool_t enterpress_forces_submit;
|
bool enterpress_forces_submit;
|
||||||
bool_t middle_click_opens_new_tab;
|
bool middle_click_opens_new_tab;
|
||||||
bool_t right_click_closes_tab;
|
bool right_click_closes_tab;
|
||||||
bool_t scroll_switches_tabs;
|
bool scroll_switches_tabs;
|
||||||
bool_t scroll_switches_tabs_reverse;
|
bool scroll_switches_tabs_reverse;
|
||||||
bool_t search_url_idx;
|
bool search_url_idx;
|
||||||
Dlist *search_urls;
|
Dlist *search_urls;
|
||||||
char *save_dir;
|
char *save_dir;
|
||||||
bool_t show_msg;
|
bool show_msg;
|
||||||
bool_t show_extra_warnings;
|
bool show_extra_warnings;
|
||||||
bool_t middle_click_drags_page;
|
bool middle_click_drags_page;
|
||||||
int penalty_hyphen, penalty_hyphen_2;
|
int penalty_hyphen, penalty_hyphen_2;
|
||||||
int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2;
|
int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2;
|
||||||
int stretchability_factor;
|
int stretchability_factor;
|
||||||
|
@ -73,7 +73,7 @@ static int parseOption(char *name, char *value,
|
|||||||
|
|
||||||
switch (node->type) {
|
switch (node->type) {
|
||||||
case PREFS_BOOL:
|
case PREFS_BOOL:
|
||||||
*(bool_t *)node->pref = (!dStrAsciiCasecmp(value, "yes") ||
|
*(bool *)node->pref = (!dStrAsciiCasecmp(value, "yes") ||
|
||||||
!dStrAsciiCasecmp(value, "true"));
|
!dStrAsciiCasecmp(value, "true"));
|
||||||
break;
|
break;
|
||||||
case PREFS_COLOR:
|
case PREFS_COLOR:
|
||||||
|
@ -1245,7 +1245,7 @@ void a_UIcmd::a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
|
|||||||
/*
|
/*
|
||||||
* Popup the page menu
|
* Popup the page menu
|
||||||
*/
|
*/
|
||||||
void a_UIcmd::a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls)
|
void a_UIcmd::a_UIcmd_page_popup(void *vbw, bool has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls)
|
||||||
{
|
{
|
||||||
BrowserWindow *bw = (BrowserWindow*)vbw;
|
BrowserWindow *bw = (BrowserWindow*)vbw;
|
||||||
const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
|
const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
|
||||||
@ -1263,7 +1263,7 @@ void a_UIcmd::a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl
|
|||||||
/*
|
/*
|
||||||
* Pop up the image menu
|
* Pop up the image menu
|
||||||
*/
|
*/
|
||||||
void a_UIcmd::a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
|
void a_UIcmd::a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool loaded_img,
|
||||||
DilloUrl *page_url, DilloUrl *link_url)
|
DilloUrl *page_url, DilloUrl *link_url)
|
||||||
{
|
{
|
||||||
a_Menu_image_popup((BrowserWindow*)vbw, url, loaded_img, page_url,link_url);
|
a_Menu_image_popup((BrowserWindow*)vbw, url, loaded_img, page_url,link_url);
|
||||||
@ -1273,7 +1273,7 @@ void a_UIcmd::a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_
|
|||||||
* Pop up the form menu
|
* Pop up the form menu
|
||||||
*/
|
*/
|
||||||
void a_UIcmd::a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
|
void a_UIcmd::a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
|
||||||
bool_t showing_hiddens)
|
bool showing_hiddens)
|
||||||
{
|
{
|
||||||
a_Menu_form_popup((BrowserWindow*)vbw, url, vform, showing_hiddens);
|
a_Menu_form_popup((BrowserWindow*)vbw, url, vform, showing_hiddens);
|
||||||
}
|
}
|
||||||
|
@ -56,12 +56,12 @@ void a_UIcmd_findtext_reset(BrowserWindow *bw);
|
|||||||
void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on);
|
void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on);
|
||||||
void a_UIcmd_focus_main_area(BrowserWindow *bw);
|
void a_UIcmd_focus_main_area(BrowserWindow *bw);
|
||||||
void a_UIcmd_focus_location(void *vbw);
|
void a_UIcmd_focus_location(void *vbw);
|
||||||
void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls);
|
void a_UIcmd_page_popup(void *vbw, bool has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls);
|
||||||
void a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl *page_url);
|
void a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl *page_url);
|
||||||
void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
|
void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool loaded_img,
|
||||||
DilloUrl *page_url, DilloUrl *link_url);
|
DilloUrl *page_url, DilloUrl *link_url);
|
||||||
void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
|
void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
|
||||||
bool_t showing_hiddens);
|
bool showing_hiddens);
|
||||||
void a_UIcmd_file_popup(void *vbw, void *v_wid);
|
void a_UIcmd_file_popup(void *vbw, void *v_wid);
|
||||||
void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr);
|
void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr);
|
||||||
void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url);
|
void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url);
|
||||||
|
15
src/url.cc
15
src/url.cc
@ -420,7 +420,7 @@ std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url)
|
|||||||
dFree(str1);
|
dFree(str1);
|
||||||
dFree(str2);
|
dFree(str2);
|
||||||
|
|
||||||
bool_t switch_to_https = FALSE;
|
bool switch_to_https = false;
|
||||||
|
|
||||||
if (url->scheme && !dStrAsciiCasecmp(url->scheme, "http")) {
|
if (url->scheme && !dStrAsciiCasecmp(url->scheme, "http")) {
|
||||||
/*
|
/*
|
||||||
@ -430,10 +430,10 @@ std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url)
|
|||||||
if (prefs.http_strict_transport_security &&
|
if (prefs.http_strict_transport_security &&
|
||||||
a_Hsts_require_https(a_Url_hostname(url.get()))) {
|
a_Hsts_require_https(a_Url_hostname(url.get()))) {
|
||||||
_MSG("url: HSTS transformation for %s.\n", url->url_string->str);
|
_MSG("url: HSTS transformation for %s.\n", url->url_string->str);
|
||||||
switch_to_https = TRUE;
|
switch_to_https = true;
|
||||||
} else if (prefs.http_force_https) {
|
} else if (prefs.http_force_https) {
|
||||||
_MSG("url: Force HTTPS transformation for %s.\n", url->url_string->str);
|
_MSG("url: Force HTTPS transformation for %s.\n", url->url_string->str);
|
||||||
switch_to_https = TRUE;
|
switch_to_https = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,15 +773,14 @@ static const char *Url_host_find_public_suffix(const char *host)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t a_Url_same_organization(const DilloUrl &u1_, const DilloUrl &u2_)
|
bool a_Url_same_organization(const DilloUrl &u1_, const DilloUrl &u2_)
|
||||||
{
|
{
|
||||||
const DilloUrl *const u1= &u1_;
|
const DilloUrl *const u1= &u1_;
|
||||||
const DilloUrl *const u2= &u2_;
|
const DilloUrl *const u2= &u2_;
|
||||||
|
|
||||||
if (!u1 || !u2)
|
if (!u1 || !u2)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return dStrAsciiCasecmp(Url_host_find_public_suffix(URL_HOST(u1)),
|
return not( dStrAsciiCasecmp(Url_host_find_public_suffix(URL_HOST(u1)),
|
||||||
Url_host_find_public_suffix(URL_HOST(u2)))
|
Url_host_find_public_suffix(URL_HOST(u2))) );
|
||||||
? FALSE : TRUE;
|
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ std::optional< std::string > a_Url_decode_hex_str(const char *str);
|
|||||||
std::optional< std::string > a_Url_encode_hex_str(const char *str);
|
std::optional< std::string > a_Url_encode_hex_str(const char *str);
|
||||||
std::optional< std::string > a_Url_string_strip_delimiters(const char *str);
|
std::optional< std::string > a_Url_string_strip_delimiters(const char *str);
|
||||||
int a_Url_host_type(const char *host);
|
int a_Url_host_type(const char *host);
|
||||||
bool_t a_Url_same_organization(const DilloUrl &u1, const DilloUrl &u2);
|
bool a_Url_same_organization(const DilloUrl &u1, const DilloUrl &u2);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -73,9 +73,9 @@ int a_Utf8_test(const char* src, unsigned int srclen)
|
|||||||
* for what might make the most sense for Dillo. Surprisingly, they include
|
* for what might make the most sense for Dillo. Surprisingly, they include
|
||||||
* Hangul Compatibility Jamo, but they're the experts, so I'll follow along.
|
* Hangul Compatibility Jamo, but they're the experts, so I'll follow along.
|
||||||
*/
|
*/
|
||||||
bool_t a_Utf8_ideographic(const char *s, const char *end, int *len)
|
bool a_Utf8_ideographic(const char *s, const char *end, int *len)
|
||||||
{
|
{
|
||||||
bool_t ret = FALSE;
|
bool ret = false;
|
||||||
|
|
||||||
if ((uchar_t)*s >= 0xe2) {
|
if ((uchar_t)*s >= 0xe2) {
|
||||||
/* Unicode char >= U+2000. */
|
/* Unicode char >= U+2000. */
|
||||||
@ -85,7 +85,7 @@ bool_t a_Utf8_ideographic(const char *s, const char *end, int *len)
|
|||||||
((unicode <= 0xa4cf) ||
|
((unicode <= 0xa4cf) ||
|
||||||
(unicode >= 0xf900 && unicode <= 0xfaff) ||
|
(unicode >= 0xf900 && unicode <= 0xfaff) ||
|
||||||
(unicode >= 0xff00 && unicode <= 0xff9f))) {
|
(unicode >= 0xff00 && unicode <= 0xff9f))) {
|
||||||
ret = TRUE;
|
ret = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*len = 1 + (int)a_Utf8_end_of_char(s, 0);
|
*len = 1 + (int)a_Utf8_end_of_char(s, 0);
|
||||||
@ -93,7 +93,7 @@ bool_t a_Utf8_ideographic(const char *s, const char *end, int *len)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t a_Utf8_combining_char(int unicode)
|
bool a_Utf8_combining_char(int unicode)
|
||||||
{
|
{
|
||||||
return ((unicode >= 0x0300 && unicode <= 0x036f) ||
|
return ((unicode >= 0x0300 && unicode <= 0x036f) ||
|
||||||
(unicode >= 0x1dc0 && unicode <= 0x1dff) ||
|
(unicode >= 0x1dc0 && unicode <= 0x1dff) ||
|
||||||
|
@ -22,8 +22,8 @@ uint_t a_Utf8_end_of_char(const char *str, uint_t i);
|
|||||||
uint_t a_Utf8_decode(const char*, const char* end, int* len);
|
uint_t a_Utf8_decode(const char*, const char* end, int* len);
|
||||||
int a_Utf8_encode(unsigned int ucs, char *buf);
|
int a_Utf8_encode(unsigned int ucs, char *buf);
|
||||||
int a_Utf8_test(const char* src, unsigned int srclen);
|
int a_Utf8_test(const char* src, unsigned int srclen);
|
||||||
bool_t a_Utf8_ideographic(const char *s, const char *end, int *len);
|
bool a_Utf8_ideographic(const char *s, const char *end, int *len);
|
||||||
bool_t a_Utf8_combining_char(int unicode);
|
bool a_Utf8_combining_char(int unicode);
|
||||||
int a_Utf8_char_count(const char *str, int len);
|
int a_Utf8_char_count(const char *str, int len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Reference in New Issue
Block a user