From e5ba0db78af3c1f04359509eec251d80d76d99f8 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 16 Nov 2017 04:34:29 -0500 Subject: [PATCH] Escape download link --- include/util/request.hpp | 1 + src/plugin.cpp | 4 ++-- src/util/request.cpp | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/util/request.hpp b/include/util/request.hpp index 2626cdda..d0405155 100644 --- a/include/util/request.hpp +++ b/include/util/request.hpp @@ -18,5 +18,6 @@ enum RequestMethod { json_t *requestJson(RequestMethod method, std::string url, json_t *dataJ); /** Returns the filename, blank if unsuccessful */ bool requestDownload(std::string url, std::string filename, float *progress); +std::string requestEscape(std::string s); } // namespace rack diff --git a/src/plugin.cpp b/src/plugin.cpp index 1c1a56f4..a2be13bf 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -237,9 +237,9 @@ static void refreshPurchase(json_t *pluginJ) { url += "?product="; url += slug; url += "&version="; - url += gApplicationVersion; + url += requestEscape(gApplicationVersion); url += "&token="; - url += gToken; + url += requestEscape(gToken); // If plugin is not loaded, download the zip file to /plugins downloadName = name; diff --git a/src/util/request.cpp b/src/util/request.cpp index 1bb0e507..c046bbb7 100644 --- a/src/util/request.cpp +++ b/src/util/request.cpp @@ -143,5 +143,15 @@ bool requestDownload(std::string url, std::string filename, float *progress) { return res == CURLE_OK; } +std::string requestEscape(std::string s) { + CURL *curl = curl_easy_init(); + assert(curl); + char *escaped = curl_easy_escape(curl, s.c_str(), s.size()); + std::string ret = escaped; + curl_free(escaped); + curl_easy_cleanup(curl); + return ret; +} + } // namespace rack