Another string simplification.

At some point using `std::filesystem::path` would be
warranted.  Better to simply clean up memory issues first, though.

Then we can see what changes.
This commit is contained in:
2025-03-02 02:09:15 -05:00
parent 982684e36c
commit d1fa4d5cca

View File

@ -370,17 +370,18 @@ static void setColors()
*/
static DilloUrl *makeStartUrl(char *str, bool local)
{
using namespace std::literals::string_literals;
std::string url_str;
char *p;
std::string p;
DilloUrl *start_url;
/* Relative path to a local file? */
p = (*str == '/') ? dStrdup(str) :
dStrconcat(Paths::getOldWorkingDir(), "/", str, NULL);
p = (*str == '/') ? str :
Paths::getOldWorkingDir() + "/"s + str;
if (access(p, F_OK) == 0) {
if (access(p.c_str(), F_OK) == 0) {
/* absolute path may have non-URL characters */
url_str = a_Misc_escape_chars(p, "% #");
url_str = a_Misc_escape_chars(p.c_str(), "% #");
start_url = a_Url_new(url_str.c_str() + 1, "file:/");
} else {
/* Not a file, filter URL string */
@ -389,7 +390,6 @@ static DilloUrl *makeStartUrl(char *str, bool local)
dFree( tmp );
start_url = a_Url_new(url_str.c_str(), NULL);
}
dFree(p);
if (local)
a_Url_set_flags(start_url, URL_FLAGS(start_url) | URL_SpamSafe);