Mercurial > dillo_port1.3
changeset 1090:ea72d116c3e2
Replace %20 and ' ' with '_' in the suggested filename for saving
author | Jorge Arellano Cid <jcid@dillo.org> |
---|---|
date | Sun, 10 May 2009 15:21:17 -0400 |
parents | 5e31d36910b3 |
children | 6bcaef79ef48 |
files | src/uicmd.cc |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/uicmd.cc Sun May 10 13:44:38 2009 -0400 +++ b/src/uicmd.cc Sun May 10 15:21:17 2009 -0400 @@ -684,14 +684,23 @@ static char *UIcmd_make_save_filename(const char *pathstr) { size_t MaxLen = 64; - char *FileName, *name; + char *FileName, *name, *newname, *o, *n; const char *dir = a_UIcmd_get_save_dir(); if ((name = strrchr(pathstr, '/'))) { if (strlen(++name) > MaxLen) { name = name + strlen(name) - MaxLen; } - FileName = dStrconcat(dir ? dir : "", name, NULL); + /* Replace %20 and ' ' with '_' in Filename */ + o = n = newname = dStrdup(name); + for (int i = 0; o[i]; i++) { + *n++ = (o[i] == ' ') ? '_' : + (o[i] == '%' && o[i+1] == '2' && o[i+2] == '0') ? + i+=2, '_' : o[i]; + } + *n = 0; + FileName = dStrconcat(dir ? dir : "", newname, NULL); + dFree(newname); } else { FileName = dStrconcat(dir ? dir : "", pathstr, NULL); }