summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2012-07-17 20:34:11 +0200
committerportix <none@none>2012-07-17 20:34:11 +0200
commitbec6b431b3d5266b73d6fb76956a81e813733049 (patch)
tree03b51b855aec16dc546d9387dcc7d939fed87cd3 /src
parent71c8610b5ac009f2b9781be7d707380740ba6412 (diff)
downloaddwb-bec6b431b3d5266b73d6fb76956a81e813733049.zip
Replace slash with underscore in download-filenames, fixes #201
Diffstat (limited to 'src')
-rw-r--r--src/download.c3
-rw-r--r--src/util.c9
-rw-r--r--src/util.h1
3 files changed, 13 insertions, 0 deletions
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<length-1; i++, filename++, buffer++) {
+ *buffer = *filename == '/' ? '_' : *filename;
+ }
+ *buffer = 0;
+ return tmp;
+}
/* util_set_file_content(const char *filename, const char *content) {{{*/
gboolean
util_set_file_content(const char *filename, const char *content) {
diff --git a/src/util.h b/src/util.h
index 4e8bc398..701a084e 100644
--- a/src/util.h
+++ b/src/util.h
@@ -49,6 +49,7 @@ int util_web_settings_sort_first(WebSettings *, WebSettings *);
// files
char * util_expand_home(char *buffer, const char *filename, size_t length);
+char * util_normalize_filename(char *buffer, const char *filename, size_t length);
void util_get_directory_content(GString *, const char *, const char *extension);
char * util_get_file_content(const char *);
char ** util_get_lines(const char *);