URI header now returns pointers with ownership.
I've put `.release()` at most of the callsites, but this gives me something to search for when taking the next steps.
This commit is contained in:
30
src/cache.cc
30
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user