diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index cbd072e6..8899dc4e 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -47,6 +47,10 @@ #include "diskspace.h" #include "signing.h" +#ifdef HAVE_LIBCURL +#include +#endif + /** Check for new version of pkg in sync repos * (only the first occurrence is considered in sync) */ @@ -763,9 +767,12 @@ static int download_single_file(alpm_handle_t *handle, struct dload_payload *pay size_t len; /* print server + filename into a buffer */ - len = strlen(server_url) + strlen(payload->remote_name) + 2; + CURL *curl = curl_easy_init(); + char *output = curl_easy_escape(curl, payload->remote_name, 0); + len = strlen(server_url) + strlen(output) + 2; MALLOC(payload->fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); - snprintf(payload->fileurl, len, "%s/%s", server_url, payload->remote_name); + snprintf(payload->fileurl, len, "%s/%s", server_url, output); + curl_free(output); if(_alpm_download(payload, cachedir, NULL, NULL) != -1) { event.type = ALPM_EVENT_PKGDOWNLOAD_DONE;