From 56be517082d732c09a93743951d2f8ee09b830d88e0fdfb020a054ebe3144a5c Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Tue, 5 Aug 2025 22:36:09 -0400 Subject: [PATCH] Another URL in `DilloHtml`. --- src/form.cc | 4 ++-- src/html.cc | 26 +++++++++++--------------- src/html_common.hh | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/form.cc b/src/form.cc index 8380756..a4f5d31 100644 --- a/src/form.cc +++ b/src/form.cc @@ -360,7 +360,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("
requires action attribute."); - action = a_Url_dup(html->base_url); + action = a_Url_dup(html->base_url.get()); } content_type = DILLO_HTML_ENC_URLENCODED; if ((method == DILLO_HTML_METHOD_POST) && @@ -584,7 +584,7 @@ void Html_tag_open_isindex(DilloHtml *html, const char *tag, int tagsize) if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "action"))) action = a_Html_url_new(html, attrbuf, NULL, 0); else - action = a_Url_dup(html->base_url); + action = a_Url_dup(html->base_url.get()); html->formNew(DILLO_HTML_METHOD_GET, action.get(), DILLO_HTML_ENC_URLENCODED, html->charset.has_value() ? html->charset.value().c_str() : nullptr); diff --git a/src/html.cc b/src/html.cc index 75577f1..4dd53bb 100644 --- a/src/html.cc +++ b/src/html.cc @@ -191,7 +191,7 @@ std::unique_ptr< DilloUrl > a_Html_url_new(DilloHtml *html, } std::unique_ptr< DilloUrl > url = a_Url_new(url_str, - (use_base_url) ? base_url : URL_STR_(html->base_url)); + (use_base_url) ? base_url : URL_STR_(html->base_url.get())); if (!url) { BUG_MSG("URL is not valid '%s'.", url_str); @@ -446,7 +446,7 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, /* Init main variables */ bw = p_bw; page_url = a_Url_dup(url); - base_url = a_Url_dup(url).release(); + base_url = a_Url_dup(url); dw = NULL; /* Init event receiver */ @@ -473,7 +473,7 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, DocType = DT_NONE; /* assume Tag Soup 0.0! :-) */ DocTypeVersion = 0.0f; - styleEngine = std::make_unique< StyleEngine >(HT2LT (this), page_url.get(), base_url, bw->zoom); + styleEngine = std::make_unique< StyleEngine >(HT2LT (this), page_url.get(), base_url.get(), bw->zoom); stack = new misc::SimpleVector (16); stack->increase(); @@ -547,8 +547,6 @@ DilloHtml::~DilloHtml() freeParseData(); a_Bw_remove_doc(bw, this); - - delete base_url; } /** @@ -1747,7 +1745,7 @@ static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize) static void Html_tag_close_style(DilloHtml *html) { if (prefs.parse_embedded_css && html->loadCssFromStash) - html->styleEngine->parse(html, html->base_url, html->Stash->str, + html->styleEngine->parse(html, html->base_url.get(), html->Stash->str, html->Stash->len, CSS_ORIGIN_AUTHOR); } @@ -3131,7 +3129,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize) auto new_url = a_Html_url_new(html, mr_url, NULL, 0); - if (a_Url_cmp(html->base_url, new_url.get()) == 0) { + if (a_Url_cmp(html->base_url.get(), new_url.get()) == 0) { /* redirection loop, or empty url string: ignore */ BUG_MSG(" refresh: %s.", *mr_url ? "redirection loop" : "no target URL"); @@ -3298,25 +3296,23 @@ static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize) static void Html_tag_open_base(DilloHtml *html, const char *tag, int tagsize) { const char *attrbuf; - DilloUrl *BaseUrl; + std::unique_ptr< DilloUrl > BaseUrl; if (html->InFlags & IN_HEAD) { if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "href"))) { bool_t html5 = html->DocType == DT_HTML && html->DocTypeVersion >= 5.0f; - BaseUrl = html5 ? a_Html_url_new(html, attrbuf, NULL, 0).release() : - a_Html_url_new(html, attrbuf, "", 1).release(); + BaseUrl = html5 ? a_Html_url_new(html, attrbuf, NULL, 0) : + a_Html_url_new(html, attrbuf, "", 1); - if (html5 || URL_SCHEME_(BaseUrl)) { + if (html5 || URL_SCHEME_(BaseUrl.get())) { /* Pass the URL_SpamSafe flag to the new base url */ a_Url_set_flags( - BaseUrl, URL_FLAGS(html->base_url) & URL_SpamSafe); - delete html->base_url; - html->base_url = BaseUrl; + BaseUrl.get(), URL_FLAGS(html->base_url) & URL_SpamSafe); + html->base_url = std::move( BaseUrl ); } else { BUG_MSG(" URI is relative (it MUST be absolute)."); - delete BaseUrl; } } } else { diff --git a/src/html_common.hh b/src/html_common.hh index 2854468..dd47f14 100644 --- a/src/html_common.hh +++ b/src/html_common.hh @@ -168,7 +168,7 @@ public: //BUG: for now everything is public BrowserWindow *bw; std::unique_ptr< DilloUrl > page_url; - DilloUrl *base_url; + std::unique_ptr< DilloUrl > base_url; dw::core::Widget *dw; /* this is duplicated in the stack */ /* -------------------------------------------------------------------*/