diff options
author | Colomban Wendling <[email protected]> | 2024-01-23 18:00:27 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2024-02-01 00:00:33 +0100 |
commit | 079240123f8de4e875996d08258554a53fd2b804 (patch) | |
tree | 05a2dacbb9f60302e724d221a2ee1f2dcbd07293 /src/file-utils.c | |
parent | 3dc5ae8a54eec467c89bf1619bf15493a6f7957c (diff) | |
download | engrampa-079240123f8de4e875996d08258554a53fd2b804.tar.bz2 engrampa-079240123f8de4e875996d08258554a53fd2b804.tar.xz |
Fix double URI escaping
Diffstat (limited to 'src/file-utils.c')
-rw-r--r-- | src/file-utils.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/file-utils.c b/src/file-utils.c index 249512d..ff5df3f 100644 --- a/src/file-utils.c +++ b/src/file-utils.c @@ -1040,25 +1040,31 @@ uricmp (const char *uri1, return g_strcmp0 (uri1, uri2); } +/** + * get_alternative_uri: + * @folder_uri: The URI of the containing folder + * @escaped_name: The URI-escaped name of the member to find a name for + * + * Tries to find an unused name for @escaped_name in @folder_uri. + * + * Returns: The full URI for the free slot (including directory) + */ char * -get_alternative_uri (const char *folder, - const char *name) +get_alternative_uri (const char *folder_uri, + const char *escaped_name) { char *new_uri = NULL; int n = 1; - char *new_name; - new_name = g_uri_escape_string (name, NULL, TRUE); do { g_free (new_uri); if (n == 1) - new_uri = g_strconcat (folder, "/", new_name, NULL); + new_uri = g_strconcat (folder_uri, "/", escaped_name, NULL); else - new_uri = g_strdup_printf ("%s/%s%%20(%d)", folder, new_name, n); + new_uri = g_strdup_printf ("%s/%s%%20(%d)", folder_uri, escaped_name, n); n++; } while (uri_exists (new_uri)); - g_free (new_name); return new_uri; } |