diff --git a/src/IO/http.cc b/src/IO/http.cc index e1c88b3..2014d7b 100644 --- a/src/IO/http.cc +++ b/src/IO/http.cc @@ -124,9 +124,9 @@ int a_Http_init(void) dStrdup(""); if (env_proxy && strlen(env_proxy)) - HTTP_Proxy = a_Url_new(env_proxy, NULL); + HTTP_Proxy = a_Url_new(env_proxy, NULL).release(); if (!HTTP_Proxy && prefs.http_proxy) - HTTP_Proxy = a_Url_dup(prefs.http_proxy); + HTTP_Proxy = a_Url_dup(*prefs.http_proxy).release(); /* This allows for storing the proxy password in "user:passwd" format * in dillorc, but as this constitutes a security problem, it was disabled. @@ -802,7 +802,7 @@ static int Http_get(ChainLink *Info, void *Data1) } hostname = dStrdup(URL_HOST(url)); S->connect_port = URL_PORT(url); - S->url = a_Url_dup(S->web->url); + S->url = a_Url_dup(*S->web->url).release(); if (!dStrAsciiCasecmp(URL_SCHEME(S->url), "https")) S->flags |= HTTP_SOCKET_TLS; diff --git a/src/IO/tls_openssl.cc b/src/IO/tls_openssl.cc index aced22d..eda261a 100644 --- a/src/IO/tls_openssl.cc +++ b/src/IO/tls_openssl.cc @@ -168,7 +168,7 @@ static int Tls_conn_new(int fd, const DilloUrl *url, SSL *ssl) Conn_t *conn = dNew0(Conn_t, 1); conn->fd = fd; - conn->url = a_Url_dup(url); + conn->url = a_Url_dup(*url).release(); conn->ssl = ssl; conn->connecting = TRUE; conn->in_connect = FALSE; diff --git a/src/auth.cc b/src/auth.cc index fd2a1a0..fede86d 100644 --- a/src/auth.cc +++ b/src/auth.cc @@ -632,7 +632,7 @@ static int Auth_do_auth_dialog(const AuthParse_t *auth_parse, "Authentication scheme: ", typestr, NULL); data = dNew(AuthDialogData_t, 1); data->auth_parse = auth_parse; - data->url = a_Url_dup(url); + data->url = a_Url_dup(*url).release(); ret = a_Dialog_user_password(title, msg, Auth_do_auth_dialog_cb, data); dFree(title); dFree(msg); delete const_cast< DilloUrl * >( data->url ); diff --git a/src/bw.cc b/src/bw.cc index c20d734..4d61df7 100644 --- a/src/bw.cc +++ b/src/bw.cc @@ -210,8 +210,8 @@ void a_Bw_add_url(BrowserWindow *bw, const DilloUrl *Url) { dReturn_if_fail ( bw != NULL && Url != NULL ); - if (!dList_find_custom(bw->PageUrls, Url, (dCompareFunc)a_Url_cmp)) { - dList_append(bw->PageUrls, a_Url_dup(Url)); + if (!dList_find_custom(bw->PageUrls, Url, (dCompareFunc)a_Url_cmp_c)) { + dList_append(bw->PageUrls, a_Url_dup(*Url).release()); } } @@ -251,7 +251,7 @@ void *a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *url) { void *doc = NULL; - if (url && dList_find_custom(bw->PageUrls, url, (dCompareFunc)a_Url_cmp)) { + if (url && dList_find_custom(bw->PageUrls, url, (dCompareFunc)a_Url_cmp_c)) { doc = a_Bw_get_current_doc(bw); } return doc; @@ -322,18 +322,18 @@ BrowserWindow *a_Bw_get(int i) void a_Bw_expect(BrowserWindow *bw, const DilloUrl *url) { delete bw->nav_expect_url; - bw->nav_expect_url = a_Url_dup(url); + bw->nav_expect_url = a_Url_dup(*url).release(); } void a_Bw_cancel_expect(BrowserWindow *bw) { delete bw->nav_expect_url; - bw->nav_expect_url = NULL; + bw->nav_expect_url = nullptr; } bool_t a_Bw_expecting(BrowserWindow *bw) { - return (bw->nav_expect_url != NULL); + return (bw->nav_expect_url != nullptr); } const DilloUrl *a_Bw_expected_url(BrowserWindow *bw) diff --git a/src/cache.cc b/src/cache.cc index ac04dc0..8f12dda 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -98,7 +98,7 @@ static int Cache_entry_cmp(const void *v1, const void *v2) { const CacheEntry_t *d1 = reinterpret_cast< const CacheEntry_t * >( v1 ), *d2 = reinterpret_cast< const CacheEntry_t * >( v2 ); - return a_Url_cmp(d1->Url, d2->Url); + return a_Url_cmp(*d1->Url, *d2->Url); } /** @@ -109,7 +109,7 @@ static int Cache_entry_by_url_cmp(const void *v1, const void *v2) const DilloUrl *u1 = reinterpret_cast< const CacheEntry_t * >( v1 )->Url; const DilloUrl *u2 = reinterpret_cast< const DilloUrl * >( v2 ); - return a_Url_cmp(u1, u2); + return a_Url_cmp(*u1, *u2); } /** @@ -123,11 +123,10 @@ void a_Cache_init(void) /* inject the splash screen in the cache */ { - DilloUrl *url = a_Url_new("about:splash", NULL); + auto url = a_Url_new("about:splash", NULL); Dstr *ds = dStr_new(AboutSplash); - Cache_entry_inject(url, ds); + Cache_entry_inject(url.get(), ds); dStr_free(ds, 1); - delete url; } } @@ -192,7 +191,7 @@ static void Cache_client_dequeue(CacheClient_t *Client) */ static void Cache_entry_init(CacheEntry_t *NewEntry, const DilloUrl *Url) { - NewEntry->Url = a_Url_dup(Url); + NewEntry->Url = a_Url_dup(*Url).release(); NewEntry->TypeDet = NULL; NewEntry->TypeHdr = NULL; NewEntry->TypeMeta = NULL; @@ -684,7 +683,7 @@ static void Cache_parse_header(CacheEntry_t *entry) if (header[9] == '3' && header[10] == '0' && (location_str = Cache_parse_field(header, "Location"))) { /* 30x: URL redirection */ - entry->Location = a_Url_new(location_str, URL_STR_(entry->Url)); + entry->Location = a_Url_new(location_str, URL_STR_(entry->Url)).release(); if (!a_Domain_permit(entry->Url, entry->Location) || (URL_FLAGS(entry->Location) & (URL_Post + URL_Get) && @@ -772,7 +771,7 @@ static void Cache_parse_header(CacheEntry_t *entry) DilloWeb *web = reinterpret_cast< DilloWeb * >( client->Web ); if (!web->requester || - a_Url_same_organization(entry->Url, web->requester)) { + a_Url_same_organization(*entry->Url, *web->requester)) { /* If cookies are third party, don't even consider them. */ char *server_date = Cache_parse_field(header, "Date"); @@ -996,8 +995,6 @@ bool_t a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size, */ static int Cache_redirect(CacheEntry_t *entry, int Flags, BrowserWindow *bw) { - DilloUrl *NewUrl; - _MSG(" Cache_redirect: redirect_level = %d\n", bw->redirect_level); /* Don't allow redirection for SpamSafe/local URLs */ @@ -1026,11 +1023,10 @@ static int Cache_redirect(CacheEntry_t *entry, int Flags, BrowserWindow *bw) if (Flags & WEB_RootUrl) { /* Redirection of the main page */ - NewUrl = a_Url_new(URL_STR_(entry->Location), URL_STR_(entry->Url)); + auto NewUrl = a_Url_new(URL_STR_(entry->Location), URL_STR_(entry->Url)); if (entry->Flags & CA_TempRedirect) - a_Url_set_flags(NewUrl, URL_FLAGS(NewUrl) | URL_E2EQuery); - a_Nav_push(bw, NewUrl, entry->Url); - delete NewUrl; + a_Url_set_flags(*NewUrl, URL_FLAGS(NewUrl) | URL_E2EQuery); + a_Nav_push(bw, NewUrl.get(), entry->Url); } else { /* Sub entity redirection (most probably an image) */ if (!entry->Data->len) { @@ -1080,7 +1076,7 @@ static void Cache_auth_entry(CacheEntry_t *entry, BrowserWindow *bw) busy = 1; data = dNew(CacheAuthData_t, 1); data->auth = entry->Auth; - data->url = a_Url_dup(entry->Url); + data->url = a_Url_dup(*entry->Url).release(); data->bw = bw; entry->Auth = NULL; a_Timeout_add(0.0, Cache_auth_callback, data); @@ -1329,7 +1325,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) if (AbortEntry) { /* Abort the entry, remove it from cache, and maybe offer download. */ - DilloUrl *url = a_Url_dup(entry->Url); + DilloUrl *url = a_Url_dup(*entry->Url).release(); a_Capi_conn_abort_by_url(url); entry = NULL; if (OfferDownload) { @@ -1338,7 +1334,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) if (a_Cache_download_enabled(url)) { Cache_savelink_t *data = dNew(Cache_savelink_t, 1); data->bw = Client_bw; - data->url = a_Url_dup(url); + data->url = a_Url_dup(*url).release(); a_Timeout_add(0.0, Cache_savelink_cb, data); } } diff --git a/src/capi.cc b/src/capi.cc index f26ad82..7ca7d14 100644 --- a/src/capi.cc +++ b/src/capi.cc @@ -97,7 +97,7 @@ static capi_conn_t * capi_conn_t *conn; conn = dNew(capi_conn_t, 1); - conn->url = url ? a_Url_dup(url) : NULL; + conn->url = url ? a_Url_dup(*url).release() : nullptr; conn->bw = bw; conn->server = dStrdup(server); conn->datastr = dStrdup(datastr); @@ -204,7 +204,7 @@ void a_Capi_conn_abort_by_url(const DilloUrl *url) for (i = 0; i < dList_length(CapiConns); ++i) { conn = reinterpret_cast< capi_conn_t * >( dList_nth_data (CapiConns, i) ); - if (a_Url_cmp(conn->url, url) == 0) { + if (a_Url_cmp(*conn->url, *url) == 0) { if (conn->InfoSend) { a_Capi_ccc(OpAbort, 1, BCK, conn->InfoSend, NULL, NULL); } @@ -224,7 +224,7 @@ void a_Capi_conn_abort_by_url(const DilloUrl *url) void a_Capi_set_vsource_url(const DilloUrl *url) { delete CapiVsUrl; - CapiVsUrl = a_Url_dup(url); + CapiVsUrl = a_Url_dup(*url).release(); } /** @@ -435,7 +435,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData) /* allow "view source" reload upon user request */ } else { /* make the other "dpi:/" prefixed urls always reload. */ - a_Url_set_flags(web->url, URL_FLAGS(web->url) |URL_E2EQuery); + a_Url_set_flags(*web->url, URL_FLAGS(web->url) |URL_E2EQuery); reload = 1; } } diff --git a/src/cookies.cc b/src/cookies.cc index 20454ea..cbabec4 100644 --- a/src/cookies.cc +++ b/src/cookies.cc @@ -199,7 +199,7 @@ char *a_Cookies_get_query(const DilloUrl *query_url, const DilloUrl *requester) if (requester == NULL) { /* request made by user */ - } else if (!a_Url_same_organization(query_url, requester)) { + } else if (!a_Url_same_organization(*query_url, *requester)) { MSG("Cookies: not sent for request by '%s' for '%s'\n", URL_HOST(requester), URL_HOST(query_url)); return dStrdup(""); diff --git a/src/cssparser.cc b/src/cssparser.cc index 6ee9ec4..5cc8e7d 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1610,8 +1610,8 @@ char * CssParser::parseUrl() } if (urlStr) { - DilloUrl *dilloUrl = a_Url_new(urlStr->str, a_Url_str(this->baseUrl)); - char *url = dStrdup(a_Url_str(dilloUrl)); + DilloUrl *dilloUrl = a_Url_new(urlStr->str, a_Url_str(*this->baseUrl)).release(); + char *url = dStrdup(a_Url_str(*dilloUrl)); delete dilloUrl; dStr_free(urlStr, 1); return url; @@ -1666,7 +1666,7 @@ void CssParser::parseImport(DilloHtml *html) if (urlStr) { if (importSyntaxIsOK && mediaIsSelected) { MSG("CssParser::parseImport(): @import %s\n", urlStr); - DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(this->baseUrl), + DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(*this->baseUrl), this->baseUrl ? 1 : 0); a_Html_load_stylesheet(html, url); delete url; diff --git a/src/dicache.cc b/src/dicache.cc index 66cbd03..8197c07 100644 --- a/src/dicache.cc +++ b/src/dicache.cc @@ -60,7 +60,7 @@ static int Dicache_entry_cmp(const void *v1, const void *v2) { const DICacheEntry *e1 = reinterpret_cast< const DICacheEntry * >( v1 ), *e2 = reinterpret_cast< const DICacheEntry * >( v2 ); - int st = a_Url_cmp(e1->url, e2->url); + int st = a_Url_cmp(*e1->url, *e2->url); if (st == 0) { if (e2->version == DIC_Last) st = (e1->Flags & DIF_Last ? 0 : -1); @@ -133,7 +133,7 @@ static DICacheEntry *Dicache_add_entry(const DilloUrl *Url) last->Flags &= ~DIF_Last; entry->version = last->version + 1; } - entry->url = a_Url_dup(Url); + entry->url = a_Url_dup(*Url).release(); entry->Flags |= DIF_Last; dList_insert_sorted(CachedIMGs, entry, Dicache_entry_cmp); diff --git a/src/domain.cc b/src/domain.cc index 788fa0a..8d030e4 100644 --- a/src/domain.cc +++ b/src/domain.cc @@ -133,7 +133,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) return ret; } - if (a_Url_same_organization(source, dest)) + if (a_Url_same_organization(*source, *dest)) return TRUE; ret = default_deny ? FALSE : TRUE; diff --git a/src/flenser.cc b/src/flenser.cc index e12b85b..0147112 100644 --- a/src/flenser.cc +++ b/src/flenser.cc @@ -382,17 +382,17 @@ static DilloUrl *makeStartUrl(char *str, bool local) if (access(p.c_str(), F_OK) == 0) { /* absolute path may have non-URL characters */ url_str = a_Misc_escape_chars(p.c_str(), "% #"); - start_url = a_Url_new(url_str.c_str() + 1, "file:/"); + start_url = a_Url_new(url_str.c_str() + 1, "file:/").release(); } else { /* Not a file, filter URL string */ char *const tmp= a_Url_string_strip_delimiters(str); url_str = tmp; dFree( tmp ); - start_url = a_Url_new(url_str.c_str(), NULL); + start_url = a_Url_new(url_str.c_str(), NULL).release(); } if (local) - a_Url_set_flags(start_url, URL_FLAGS(start_url) | URL_SpamSafe); + a_Url_set_flags(*start_url, URL_FLAGS(start_url) | URL_SpamSafe); return start_url; } diff --git a/src/form.cc b/src/form.cc index bf49168..bc3cc2d 100644 --- a/src/form.cc +++ b/src/form.cc @@ -377,7 +377,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) else { if (html->DocType != DT_HTML || html->DocTypeVersion <= 4.01f) BUG_MSG("