Fix of Proxy secured print host URL. Special character on password #4187

A raw URL was passed to libcurl, while it should have been URL encoded.
This commit is contained in:
Vojtech Bubnik 2020-12-03 08:07:13 +01:00
parent 597a158a6e
commit 1b720dbc3d

View File

@ -163,7 +163,13 @@ Http::priv::priv(const std::string &url)
} }
set_timeout_connect(DEFAULT_TIMEOUT_CONNECT); set_timeout_connect(DEFAULT_TIMEOUT_CONNECT);
::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); // curl makes a copy internally char *url_encoded = curl_easy_escape(curl, url.c_str(), url.size());
if (url_encoded) {
// libcurl makes an internal copy.
::curl_easy_setopt(curl, CURLOPT_URL, url_encoded);
::curl_free(url_encoded);
} else
throw Slic3r::RuntimeError(std::string("Curl failed to encode URL: ") + url);
::curl_easy_setopt(curl, CURLOPT_USERAGENT, SLIC3R_APP_NAME "/" SLIC3R_VERSION); ::curl_easy_setopt(curl, CURLOPT_USERAGENT, SLIC3R_APP_NAME "/" SLIC3R_VERSION);
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer.front()); ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer.front());
} }