Fix files with # character in url redirect

This commit is contained in:
2019-10-27 08:30:47 -04:00
parent 69f0c1f2cf
commit 4109ba6d34
4 changed files with 29 additions and 9 deletions

View File

@@ -5,6 +5,24 @@
#define PBSTR "========================================"
#define PBWIDTH 40
dyn_buffer_t url_escape(char *str) {
dyn_buffer_t text = dyn_buffer_create();
char * ptr = str;
while (*ptr) {
if (*ptr == '#') {
dyn_buffer_write(&text, "%23", 3);
ptr++;
}
dyn_buffer_write_char(&text, *ptr++);
}
dyn_buffer_write_char(&text, '\0');
return text;
}
char *abspath(const char *path) {
wordexp_t w;
wordexp(path, &w, 0);