NetSurf
Functions
urldb.h File Reference

Unified URL information database internal interface. More...

#include <libwapcaplet/libwapcaplet.h>
#include "netsurf/url_db.h"
#include "netsurf/cookie_db.h"
Include dependency graph for urldb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void urldb_destroy (void)
 Destroy urldb. More...
 
nserror urldb_set_url_persistence (struct nsurl *url, bool persist)
 Set the cross-session persistence of the entry for an URL. More...
 
bool urldb_add_url (struct nsurl *url)
 Insert an URL into the database. More...
 
nserror urldb_set_url_title (struct nsurl *url, const char *title)
 Set an URL's title string, replacing any existing one. More...
 
nserror urldb_set_url_content_type (struct nsurl *url, content_type type)
 Set an URL's content type. More...
 
void urldb_set_auth_details (struct nsurl *url, const char *realm, const char *auth)
 Set authentication data for an URL. More...
 
const char * urldb_get_auth_details (struct nsurl *url, const char *realm)
 Look up authentication details in database. More...
 
nserror urldb_update_url_visit_data (struct nsurl *url)
 Update an URL's visit data. More...
 
void urldb_reset_url_visit_data (struct nsurl *url)
 Reset an URL's visit statistics. More...
 
struct nsurlurldb_get_url (struct nsurl *url)
 Extract an URL from the db. More...
 
bool urldb_get_cert_permissions (struct nsurl *url)
 Retrieve certificate verification permissions from database. More...
 
bool urldb_set_cookie (const char *header, struct nsurl *url, struct nsurl *referrer)
 Parse Set-Cookie header and insert cookie(s) into database. More...
 
char * urldb_get_cookie (struct nsurl *url, bool include_http_only)
 Retrieve cookies for an URL. More...
 
bool urldb_set_hsts_policy (struct nsurl *url, const char *header)
 Set HSTS policy for an URL. More...
 
bool urldb_get_hsts_enabled (struct nsurl *url)
 Determine if HSTS policy is enabled for an URL. More...
 

Detailed Description

Unified URL information database internal interface.

Definition in file urldb.h.

Function Documentation

◆ urldb_add_url()

bool urldb_add_url ( struct nsurl url)

Insert an URL into the database.

Parameters
urlAbsolute URL to insert
Returns
true on success, false otherwise

Definition at line 3140 of file urldb.c.

References bloom_create(), bloom_insert_hash(), BLOOM_SIZE, path_data::fragment, NSERROR_OK, NSURL_FRAGMENT, nsurl_get(), nsurl_get_component(), nsurl_hash(), NSURL_HOST, NSURL_PATH, NSURL_PORT, NSURL_QUERY, NSURL_SCHEME, path_data::port, path_data::scheme, path_data::url, url_bloom, urldb_add_host(), and urldb_add_path().

Referenced by browser_window_callback(), browser_window_content_ready(), hotlist_create_entry(), hotlist_update_url_walk_cb(), urldb_get_auth_details(), urldb_get_cookie(), urldb_get_hsts_enabled(), urldb_set_auth_details(), urldb_set_cert_permissions(), and urldb_set_hsts_policy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_destroy()

void urldb_destroy ( void  )

Destroy urldb.

Definition at line 2847 of file urldb.c.

References bloom_destroy(), host_part::children, db_root, empty, host_part::next, NUM_SEARCH_TREES, search_trees, url_bloom, urldb_destroy_host_tree(), and urldb_destroy_search_tree().

Referenced by netsurf_exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_get_auth_details()

const char * urldb_get_auth_details ( struct nsurl url,
const char *  realm 
)

Look up authentication details in database.

Parameters
urlAbsolute URL to search for
realmWhen non-NULL, it is realm which can be used to determine the protection space when that's not been done before for given URL.
Returns
Pointer to authentication details, or NULL if not found

Definition at line 3405 of file urldb.c.

References prot_space_data::auth, prot_space_data::next, path_data::parent, prot_space_data::port, path_data::port, path_data::prot_space, host_part::prot_space, prot_space_data::realm, prot_space_data::scheme, path_data::scheme, path_data::url, urldb_add_url(), and urldb_find_url().

Referenced by browser_window__handle_login(), fetch_curl_set_options(), and llcache_fetch_auth().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_get_cert_permissions()

bool urldb_get_cert_permissions ( struct nsurl url)

Retrieve certificate verification permissions from database.

Parameters
urlAbsolute URL to search for
Returns
true to permit connections to hosts with invalid certificates, false otherwise.

Definition at line 3480 of file urldb.c.

References path_data::parent, host_part::permit_invalid_certs, and urldb_find_url().

Referenced by browser_window_get_page_info_state(), content_saw_insecure_objects(), and fetch_curl_set_options().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_get_cookie()

char * urldb_get_cookie ( struct nsurl url,
bool  include_http_only 
)

Retrieve cookies for an URL.

Parameters
urlURL being fetched
include_http_onlyWhether to include HTTP(S) only cookies.
Returns
Cookies string for libcurl (on heap), or NULL on error/no cookies

Definition at line 3997 of file urldb.c.

References path_data::children, cookie_manager_add(), COOKIE_NETSCAPE, COOKIE_RFC2965, path_data::cookies, count(), db_root, cookie_internal_data::expires, GROW_MATCHED_COOKIES, cookie_internal_data::http_only, cookie_internal_data::last_used, cookie_internal_data::next, path_data::next, nsurl_get_component(), NSURL_PATH, path_data::parent, host_part::parent, cookie_internal_data::path, path(), host_part::paths, path_data::scheme, cookie_internal_data::secure, path_data::segment, urldb_add_url(), urldb_concat_cookie(), urldb_find_url(), cookie_internal_data::version, and version.

Referenced by browser_window_get_cookie_count(), and fetch_curl_set_options().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_get_hsts_enabled()

bool urldb_get_hsts_enabled ( struct nsurl url)

Determine if HSTS policy is enabled for an URL.

Parameters
urlURL being fetched
Returns
true if HSTS policy is enabled, false otherwise

Definition at line 3573 of file urldb.c.

References db_root, hsts_data::expires, host_part::hsts, hsts_data::include_sub_domains, nsurl_get_component(), NSURL_HOST, path_data::parent, host_part::parent, urldb__host_is_ip_address(), urldb_add_url(), and urldb_find_url().

Referenced by llcache_hsts_transform_url().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_get_url()

struct nsurl * urldb_get_url ( struct nsurl url)

Extract an URL from the db.

Parameters
urlURL to extract
Returns
Pointer to database's copy of URL or NULL if not found

Definition at line 3327 of file urldb.c.

References path_data::url, and urldb_find_url().

Referenced by browser_window_content_ready().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_reset_url_visit_data()

void urldb_reset_url_visit_data ( struct nsurl url)

Reset an URL's visit statistics.

Parameters
urlThe URL to reset

Definition at line 3293 of file urldb.c.

References url_internal_data::last_visit, path_data::url, path_data::urld, urldb_find_url(), and url_internal_data::visits.

Referenced by global_history_delete_entry_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_set_auth_details()

void urldb_set_auth_details ( struct nsurl url,
const char *  realm,
const char *  auth 
)

Set authentication data for an URL.

Parameters
urlThe URL to consider
realmThe authentication realm
authThe authentication details (in form username:password)

Definition at line 3342 of file urldb.c.

References prot_space_data::auth, prot_space_data::next, path_data::parent, prot_space_data::port, path_data::port, path_data::prot_space, host_part::prot_space, prot_space_data::realm, prot_space_data::scheme, path_data::scheme, urldb_add_url(), and urldb_find_url().

Referenced by browser_window__handle_userpass_response(), and navigate_internal_query_auth().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_set_cookie()

bool urldb_set_cookie ( const char *  header,
struct nsurl url,
struct nsurl referrer 
)

Parse Set-Cookie header and insert cookie(s) into database.

Parameters
headerHeader to parse, with Set-Cookie: stripped
urlURL being fetched
referrerReferring resource, or 0 for verifiable transaction
Returns
true on success, false otherwise
Todo:
In future, we should consult a TLD service instead of just looking for embedded dots.

Definition at line 3734 of file urldb.c.

References cookie_internal_data::domain, cookie_internal_data::name, NSERROR_OK, NSLOG, nsurl_defragment(), nsurl_get_component(), NSURL_HOST, NSURL_PATH, NSURL_SCHEME, nsurl_unref(), cookie_internal_data::path, path(), urldb__host_is_ip_address(), urldb_free_cookie(), urldb_insert_cookie(), urldb_parse_cookie(), and cookie_internal_data::value.

Referenced by fetch_set_cookie().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_set_hsts_policy()

bool urldb_set_hsts_policy ( struct nsurl url,
const char *  header 
)

Set HSTS policy for an URL.

Parameters
urlURL being fetched
headerStrict-Transport-Security header value
Returns
true on success, false otherwise

Definition at line 3502 of file urldb.c.

References hsts_data::expires, host_part::hsts, http_parse_strict_transport_security(), http_strict_transport_security_destroy(), http_strict_transport_security_include_subdomains(), http_strict_transport_security_max_age(), hsts_data::include_sub_domains, NSERROR_OK, nsurl_get_component(), NSURL_HOST, path_data::parent, host_part::permit_invalid_certs, urldb__host_is_ip_address(), urldb_add_url(), and urldb_find_url().

Referenced by llcache_hsts_update_policy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_set_url_content_type()

nserror urldb_set_url_content_type ( struct nsurl url,
content_type  type 
)

Set an URL's content type.

Parameters
urlThe URL to look for
typeThe type to set
Returns
NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database

Definition at line 3256 of file urldb.c.

References NSERROR_NOT_FOUND, NSERROR_OK, url_internal_data::type, type, path_data::url, path_data::urld, and urldb_find_url().

Referenced by browser_window_content_ready().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_set_url_persistence()

nserror urldb_set_url_persistence ( struct nsurl url,
bool  persist 
)

Set the cross-session persistence of the entry for an URL.

Parameters
urlAbsolute URL to persist
persistTrue to persist, false otherwise
Returns
NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database

Definition at line 3122 of file urldb.c.

References NSERROR_NOT_FOUND, NSERROR_OK, path_data::persistent, path_data::url, and urldb_find_url().

Referenced by hotlist_add_entry_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_set_url_title()

nserror urldb_set_url_title ( struct nsurl url,
const char *  title 
)

Set an URL's title string, replacing any existing one.

Parameters
urlThe URL to look for
titleThe title string to use (copied)
Returns
NSERROR_OK on success otherwise appropriate error code

Definition at line 3226 of file urldb.c.

References NSERROR_NOMEM, NSERROR_NOT_FOUND, NSERROR_OK, url_internal_data::title, path_data::url, path_data::urld, and urldb_find_url().

Referenced by browser_window_content_ready().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urldb_update_url_visit_data()

nserror urldb_update_url_visit_data ( struct nsurl url)

Update an URL's visit data.

Parameters
urlThe URL to update
Returns
NSERROR_OK on success or NSERROR_NOT_FOUND if url not in database

Definition at line 3274 of file urldb.c.

References url_internal_data::last_visit, NSERROR_NOT_FOUND, NSERROR_OK, path_data::url, path_data::urld, urldb_find_url(), and url_internal_data::visits.

Referenced by browser_window_callback(), and browser_window_content_ready().

Here is the call graph for this function:
Here is the caller graph for this function: