PresetUpdater: Fix: Sanitize downloadedsemver, fix #2927

Use HTTPS for the slicer app version url
This commit is contained in:
Vojtech Kral 2019-09-16 17:51:31 +02:00
parent c38e537adc
commit 8e11a7b895
2 changed files with 11 additions and 1 deletions

View File

@ -26,7 +26,7 @@ namespace Slic3r {
static const std::string VENDOR_PREFIX = "vendor:"; static const std::string VENDOR_PREFIX = "vendor:";
static const std::string MODEL_PREFIX = "model:"; static const std::string MODEL_PREFIX = "model:";
static const std::string VERSION_CHECK_URL = "http://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version"; static const std::string VERSION_CHECK_URL = "https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version";
void AppConfig::reset() void AppConfig::reset()
{ {

View File

@ -245,6 +245,16 @@ void PresetUpdater::priv::sync_version() const
}) })
.on_complete([&](std::string body, unsigned /* http_status */) { .on_complete([&](std::string body, unsigned /* http_status */) {
boost::trim(body); boost::trim(body);
const auto nl_pos = body.find_first_of("\n\r");
if (nl_pos != std::string::npos) {
body.resize(nl_pos);
}
if (! Semver::parse(body)) {
BOOST_LOG_TRIVIAL(warning) << boost::format("Received invalid contents from `%1%`: Not a correct semver: `%2%`") % SLIC3R_APP_NAME % body;
return;
}
BOOST_LOG_TRIVIAL(info) << boost::format("Got %1% online version: `%2%`. Sending to GUI thread...") % SLIC3R_APP_NAME % body; BOOST_LOG_TRIVIAL(info) << boost::format("Got %1% online version: `%2%`. Sending to GUI thread...") % SLIC3R_APP_NAME % body;
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE); wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);