Dillo v3.1.1-98-g318d1f14
|
Parse and normalize all URL's inside Dillo. More...
Go to the source code of this file.
Classes | |
struct | DilloUrl |
Macros | |
#define | URL_HTTP_PORT 80 |
#define | URL_HTTPS_PORT 443 |
#define | URL_HOST_ERROR -1 |
#define | URL_HOST_NAME 0 |
#define | URL_HOST_IPV4 1 |
#define | URL_HOST_IPV6 2 |
#define | URL_Get (1 << 0) |
#define | URL_Post (1 << 1) |
#define | URL_E2EQuery (1 << 5) |
#define | URL_ReloadPage (1 << 7) |
#define | URL_ReloadFromCache (1 << 8) |
#define | URL_IgnoreScroll (1 << 9) |
#define | URL_SpamSafe (1 << 10) |
#define | URL_MultipartEnc (1 << 11) |
#define | URL_SCHEME_(u) (u)->scheme |
#define | URL_AUTHORITY_(u) (u)->authority |
#define | URL_PATH_(u) (u)->path |
#define | URL_QUERY_(u) (u)->query |
#define | URL_FRAGMENT_(u) (u)->fragment |
#define | URL_HOST_(u) a_Url_hostname(u) |
#define | URL_STR_(u) a_Url_str(u) |
#define | URL_DATA_(u) (u)->data |
#define | URL_PORT_(u) (URL_HOST(u), (u)->port) |
#define | URL_FLAGS_(u) (u)->flags |
#define | URL_ILLEGAL_CHARS_(u) (u)->illegal_chars |
#define | URL_ILLEGAL_CHARS_SPC_(u) (u)->illegal_chars_spc |
#define | NPTR2STR(p) ((p) ? (p) : "") |
#define | URL_SCHEME(u) NPTR2STR(URL_SCHEME_(u)) |
#define | URL_AUTHORITY(u) NPTR2STR(URL_AUTHORITY_(u)) |
#define | URL_PATH(u) NPTR2STR(URL_PATH_(u)) |
#define | URL_QUERY(u) NPTR2STR(URL_QUERY_(u)) |
#define | URL_FRAGMENT(u) NPTR2STR(URL_FRAGMENT_(u)) |
#define | URL_HOST(u) NPTR2STR(URL_HOST_(u)) |
#define | URL_STR(u) NPTR2STR(URL_STR_(u)) |
#define | URL_DATA(u) URL_DATA_(u) |
#define | URL_PORT(u) URL_PORT_(u) |
#define | URL_FLAGS(u) URL_FLAGS_(u) |
#define | URL_ILLEGAL_CHARS(u) URL_ILLEGAL_CHARS_(u) |
#define | URL_ILLEGAL_CHARS_SPC(u) URL_ILLEGAL_CHARS_SPC_(u) |
Functions | |
DilloUrl * | a_Url_new (const char *url_str, const char *base_url) |
Transform (and resolve) an URL string into the respective DilloURL. | |
void | a_Url_free (DilloUrl *u) |
Free a DilloUrl. | |
char * | a_Url_str (const DilloUrl *url) |
Return the url as a string. | |
const char * | a_Url_hostname (const DilloUrl *u) |
Return the hostname as a string. | |
DilloUrl * | a_Url_dup (const DilloUrl *u) |
Duplicate a Url structure. | |
int | a_Url_cmp (const DilloUrl *A, const DilloUrl *B) |
Compare two Url's to check if they're the same, or which one is bigger. | |
void | a_Url_set_flags (DilloUrl *u, int flags) |
Set DilloUrl flags. | |
void | a_Url_set_data (DilloUrl *u, Dstr **data) |
Set DilloUrl data (like POST info, etc.) | |
void | a_Url_set_ismap_coords (DilloUrl *u, char *coord_str) |
Set DilloUrl ismap coordinates. | |
char * | a_Url_decode_hex_str (const char *str) |
Parse possible hexadecimal octets in the URI path. | |
char * | a_Url_encode_hex_str (const char *str) |
Urlencode 'str'. | |
char * | a_Url_string_strip_delimiters (const char *str) |
RFC-3986 suggests this stripping when "importing" URLs from other media. | |
int | a_Url_host_type (const char *host) |
What type of host is this? | |
bool_t | a_Url_same_organization (const DilloUrl *u1, const DilloUrl *u2) |
Parse and normalize all URL's inside Dillo.
Definition in file url.h.
#define URL_AUTHORITY | ( | u | ) | NPTR2STR(URL_AUTHORITY_(u)) |
#define URL_FLAGS | ( | u | ) | URL_FLAGS_(u) |
#define URL_FRAGMENT | ( | u | ) | NPTR2STR(URL_FRAGMENT_(u)) |
#define URL_HOST_ | ( | u | ) | a_Url_hostname(u) |
#define URL_ILLEGAL_CHARS | ( | u | ) | URL_ILLEGAL_CHARS_(u) |
#define URL_ILLEGAL_CHARS_SPC | ( | u | ) | URL_ILLEGAL_CHARS_SPC_(u) |
#define URL_QUERY | ( | u | ) | NPTR2STR(URL_QUERY_(u)) |
#define URL_SCHEME | ( | u | ) | NPTR2STR(URL_SCHEME_(u)) |
Compare two Url's to check if they're the same, or which one is bigger.
The fields which are compared here are: <scheme>, <authority>, <path>, <query> and <data> Other fields are left for the caller to check
Return value: 0 if equal, > 0 if A > B, < 0 if A < B.
Note: this function defines a sorting order different from strcmp!
Definition at line 506 of file url.c.
References DilloUrl::authority, DilloUrl::data, dReturn_val_if_fail, dStr_cmp(), DilloUrl::path, DilloUrl::query, DilloUrl::scheme, URL_STR_FIELD_CMP, and URL_STR_FIELD_I_CMP.
Referenced by a_Bw_add_url(), a_Bw_get_url_doc(), a_Capi_conn_abort_by_url(), a_History_add_url(), a_History_get_title_by_url(), a_History_set_title_by_url(), a_Nav_cancel_expect_if_eq(), a_Nav_push(), Cache_entry_by_url_cmp(), Cache_entry_cmp(), Dicache_entry_cmp(), Html_tag_open_meta(), DilloHtml::loadImages(), and Nav_open_url().
char * a_Url_decode_hex_str | ( | const char * | str | ) |
Parse possible hexadecimal octets in the URI path.
Returns a new allocated string.
Definition at line 586 of file url.c.
References dNew, dRealloc(), dStrdup(), and Url_decode_hex_octet().
Duplicate a Url structure.
Definition at line 477 of file url.c.
References DilloUrl::data, dReturn_val_if_fail, dStr_append_l(), dStr_new(), dStr_sized_new(), DilloUrl::flags, DilloUrl::illegal_chars, DilloUrl::illegal_chars_spc, DilloUrl::ismap_url_len, DilloUrl::port, URL_DATA, Url_object_new(), URL_STR, URL_STR_, and DilloUrl::url_string.
Referenced by a_Bw_add_url(), a_Bw_expect(), a_Capi_set_vsource_url(), a_History_add_url(), a_Http_init(), a_Menu_bugmeter_popup(), a_Menu_form_popup(), a_Menu_image_popup(), a_Menu_link_popup(), a_Menu_page_popup(), a_Nav_expect_done(), a_Nav_redirection0(), a_Web_new(), DilloHtml::addCssUrl(), Auth_do_auth_dialog(), Cache_auth_entry(), Cache_entry_init(), Cache_process_queue(), Capi_conn_new(), Dicache_add_entry(), DilloHtml::DilloHtml(), Html_tag_open_form(), Html_tag_open_isindex(), Http_get(), Nav_reload_callback(), Nav_repush(), StyleEngine::StyleEngine(), Tls_conn_new(), and Tls_conn_new().
char * a_Url_encode_hex_str | ( | const char * | str | ) |
Urlencode 'str'.
-RL :: According to the RFC 1738, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters ";/?:@=&" used for their reserved purposes may be used unencoded within a URL. We'll escape everything but alphanumeric and "-_.*" (as lynx). –Jcid
Note: the content type "application/x-www-form-urlencoded" is used: i.e., ' ' -> '+' and '
' -> CR LF (see HTML 4.01, Sec. 17.13.4)
Definition at line 620 of file url.c.
References d_isascii, dIsalnum, dNew, and HEX.
Referenced by Menu_bugmeter_validate(), and UIcmd_make_search_str().
void a_Url_free | ( | DilloUrl * | url | ) |
Free a DilloUrl.
Do nothing if the argument is NULL
Definition at line 208 of file url.c.
References DilloUrl::authority, DilloUrl::buffer, DilloUrl::data, dFree(), dStr_free(), DilloUrl::hostname, TRUE, and DilloUrl::url_string.
Referenced by a_Bw_cancel_expect(), a_Bw_cleanup(), a_Bw_expect(), a_Bw_free(), a_Cache_init(), a_Capi_set_vsource_url(), a_Dicache_freeall(), a_History_freeall(), a_Http_freeall(), a_Menu_bugmeter_popup(), a_Menu_file_popup(), a_Menu_form_popup(), a_Menu_image_popup(), a_Menu_link_popup(), a_Menu_page_popup(), a_Nav_expect_done(), a_Nav_redirection0(), a_Prefs_freeall(), a_UIcmd_book(), a_UIcmd_open_file(), a_UIcmd_open_urlstr(), a_UIcmd_view_page_source(), a_Web_free(), StyleEngine::apply(), Auth_do_auth_dialog(), Cache_auth_callback(), Cache_entry_free(), Cache_process_queue(), Cache_redirect(), Cache_savelink_cb(), Capi_conn_unref(), Dicache_remove(), Html_tag_content_img(), Html_tag_content_map(), Html_tag_open_base(), Html_tag_open_form(), Html_tag_open_isindex(), Html_tag_open_link(), Html_tag_open_meta(), Html_tag_open_object(), Http_socket_free(), main(), Nav_redirection0_callback(), Nav_reload_callback(), Nav_repush(), CssParser::parseImport(), parseOption(), CssParser::parseUrl(), Tls_close_by_key(), Tls_close_by_key(), Url_resolve_relative(), DilloHtml::~DilloHtml(), and StyleEngine::~StyleEngine().
int a_Url_host_type | ( | const char * | host | ) |
What type of host is this?
Definition at line 683 of file url.c.
References URL_HOST_ERROR, URL_HOST_IPV4, URL_HOST_IPV6, and URL_HOST_NAME.
Referenced by a_Tls_openssl_connect(), Cache_parse_header(), Tls_cert_authorities_print_summary(), and Url_host_find_public_suffix().
const char * a_Url_hostname | ( | const DilloUrl * | u | ) |
Return the hostname as a string.
(initializing 'hostname' and 'port' fields if necessary) Note: a similar approach can be taken for user:password auth.
Definition at line 98 of file url.c.
References DilloUrl::authority, dStrAsciiCasecmp(), dStrndup(), DilloUrl::hostname, DilloUrl::port, DilloUrl::scheme, URL_HTTP_PORT, and URL_HTTPS_PORT.
Referenced by a_Url_new().
DilloUrl * a_Url_new | ( | const char * | url_str, |
const char * | base_url | ||
) |
Transform (and resolve) an URL string into the respective DilloURL.
If URL = "http://dillo.sf.net:8080/index.html?long#part2" then the resulting DilloURL should be:
Return NULL if URL is badly formed.
Definition at line 371 of file url.c.
References _MSG, a_Hsts_require_https(), a_Url_hostname(), DilloUrl::authority, DilloUrl::data, dFree(), dNew, dStr_free(), dStr_new(), dStrAsciiCasecmp(), dStrconcat(), FALSE, HEX, DilloPrefs::http_force_https, DilloPrefs::http_strict_transport_security, DilloUrl::illegal_chars, DilloUrl::illegal_chars_spc, DilloUrl::port, prefs, DilloUrl::scheme, Dstr::str, TRUE, URL_HTTP_PORT, URL_HTTPS_PORT, Url_object_new(), Url_resolve_relative(), and DilloUrl::url_string.
Referenced by a_Cache_init(), a_Html_url_new(), a_Http_init(), a_Prefs_init(), a_UIcmd_book(), a_UIcmd_open_file(), a_UIcmd_open_urlstr(), a_UIcmd_view_page_source(), StyleEngine::apply(), Cache_parse_header(), Cache_redirect(), makeStartUrl(), parseOption(), and CssParser::parseUrl().
Definition at line 798 of file url.c.
References dStrAsciiCasecmp(), FALSE, TRUE, URL_HOST, and Url_host_find_public_suffix().
Referenced by a_Cookies_get_query(), a_Domain_permit(), and Cache_parse_header().
Set DilloUrl data (like POST info, etc.)
Definition at line 536 of file url.c.
References DilloUrl::data, and dStr_free().
void a_Url_set_flags | ( | DilloUrl * | u, |
int | flags | ||
) |
Set DilloUrl flags.
Definition at line 527 of file url.c.
References DilloUrl::flags.
Referenced by a_Capi_open_url(), a_Nav_expect_done(), a_Nav_redirection0(), Cache_redirect(), Html_tag_open_base(), makeStartUrl(), Nav_reload_callback(), and Nav_repush().
void a_Url_set_ismap_coords | ( | DilloUrl * | u, |
char * | coord_str | ||
) |
Set DilloUrl ismap coordinates.
(this is optimized for not hogging the CPU)
Definition at line 549 of file url.c.
References dReturn_if_fail, dStr_append(), dStr_truncate(), DilloUrl::ismap_url_len, Dstr::len, DilloUrl::query, Dstr::str, URL_STR_, and DilloUrl::url_string.
Referenced by Html_set_link_coordinates().
char * a_Url_str | ( | const DilloUrl * | u | ) |
Return the url as a string.
(initializing 'url_string' field if necessary)
Definition at line 66 of file url.c.
References DilloUrl::authority, dReturn_val_if_fail, dStr_sized_new(), dStr_sprintf(), DilloUrl::fragment, DilloUrl::path, DilloUrl::query, DilloUrl::scheme, Dstr::str, and DilloUrl::url_string.
Referenced by DilloHtml::HtmlLinkReceiver::click(), CssParser::parseImport(), and CssParser::parseUrl().
char * a_Url_string_strip_delimiters | ( | const char * | str | ) |
RFC-3986 suggests this stripping when "importing" URLs from other media.
Strip: "URL:", enclosing < >, and embedded whitespace. (We also strip illegal chars: 00-1F and 7F-FF)
Definition at line 658 of file url.c.
References dStrdup().
Referenced by a_UIcmd_open_urlstr(), and makeStartUrl().