From bec6b431b3d5266b73d6fb76956a81e813733049 Mon Sep 17 00:00:00 2001 From: portix Date: Tue, 17 Jul 2012 20:34:11 +0200 Subject: Replace slash with underscore in download-filenames, fixes #201 --- src/download.c | 3 +++ src/util.c | 9 +++++++++ src/util.h | 1 + 3 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/download.c b/src/download.c index 81827283..9f748489 100644 --- a/src/download.c +++ b/src/download.c @@ -390,6 +390,9 @@ download_start(const char *path) { WebKitNetworkRequest *request = webkit_download_get_network_request(dwb.state.download); dwb.state.download = webkit_download_new(request); + char escape_buffer[255]; + filename = util_normalize_filename(escape_buffer, filename, 255); + if (EMIT_SCRIPT(DOWNLOAD_START)) { if (dwb.state.dl_action == DL_ACTION_EXECUTE) { json = util_create_json(4, diff --git a/src/util.c b/src/util.c index e6a2aee5..7ef7c62a 100644 --- a/src/util.c +++ b/src/util.c @@ -331,6 +331,15 @@ util_expand_home(char *buffer, const char *filename, size_t length) { strncpy(buffer, filename, length); return buffer; } +char * +util_normalize_filename(char *buffer, const char *filename, size_t length) { + char *tmp = buffer; + for (int i=0; *filename != 0 && i