Various web servers, namely Amazon S3 ones, have problems handling requests
to URLs with a literal "+" in the path component.
According to the RFC 3986 "+" is a reserved char and its purpose is
delimiting. When used in a file name it should be encoded.
Use the new urlencode_path() helper to encode the path component before
constructing the final download URL.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Tested-by: Rafał Miłecki <rafal@milecki.pl>
/* download package and dependencies */
for (i = 0; i < deps->len; i++) {
pkg_t *pkg;
/* download package and dependencies */
for (i = 0; i < deps->len; i++) {
pkg_t *pkg;
+ char *url, *urlencoded_path;
pkg = deps->pkgs[i];
if (pkg_get_string(pkg, PKG_LOCAL_FILENAME))
pkg = deps->pkgs[i];
if (pkg_get_string(pkg, PKG_LOCAL_FILENAME))
}
filename = pkg_get_string(pkg, PKG_FILENAME);
}
filename = pkg_get_string(pkg, PKG_FILENAME);
-
- sprintf_alloc(&url, "%s/%s", pkg->src->value, filename);
+ urlencoded_path = urlencode_path(filename);
+ sprintf_alloc(&url, "%s/%s", pkg->src->value, urlencoded_path);
+ free(urlencoded_path);
/* Get the filename part, without any directory */
stripped_filename = strrchr(filename, '/');
/* Get the filename part, without any directory */
stripped_filename = strrchr(filename, '/');
char *url;
char *local_filename;
char *stripped_filename;
char *url;
char *local_filename;
char *stripped_filename;
char *filename;
if (pkg->src == NULL) {
char *filename;
if (pkg->src == NULL) {
- sprintf_alloc(&url, "%s/%s", pkg->src->value, filename);
+ urlencoded_path = urlencode_path(filename);
+ sprintf_alloc(&url, "%s/%s", pkg->src->value, urlencoded_path);
+ free(urlencoded_path);
/* The filename might be something like
"../../foo.opk". While this is correct, and exactly what we
/* The filename might be something like
"../../foo.opk". While this is correct, and exactly what we