Browse Source

Escape download link

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
e5ba0db78a
3 changed files with 13 additions and 2 deletions
  1. +1
    -0
      include/util/request.hpp
  2. +2
    -2
      src/plugin.cpp
  3. +10
    -0
      src/util/request.cpp

+ 1
- 0
include/util/request.hpp View File

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

+ 2
- 2
src/plugin.cpp View File

@@ -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;


+ 10
- 0
src/util/request.cpp View File

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

Loading…
Cancel
Save