Another URL in DilloHtml.

This commit is contained in:
2025-08-05 22:36:09 -04:00
parent 9c2225a633
commit 56be517082
3 changed files with 14 additions and 18 deletions

View File

@ -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("<form> 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);

View File

@ -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 <DilloHtmlState> (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("<meta> 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("<base> URI is relative (it MUST be absolute).");
delete BaseUrl;
}
}
} else {

View File

@ -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 */
/* -------------------------------------------------------------------*/