Skip to content

Instantly share code, notes, and snippets.

@smly
Last active January 9, 2019 20:33
Show Gist options
  • Save smly/37506c149f378065138c95c8a651cc46 to your computer and use it in GitHub Desktop.
Save smly/37506c149f378065138c95c8a651cc46 to your computer and use it in GitHub Desktop.
w3m patch (origin: shinh/w3m)
diff --git a/file.c b/file.c
index 6069770..76bb5e6 100644
--- a/file.c
+++ b/file.c
@@ -8526,12 +8526,14 @@ guess_save_name(Buffer *buf, char *path)
if ((p = checkHeader(buf, "Content-Disposition:")) != NULL &&
(q = strcasestr(p, "filename")) != NULL &&
(q == p || IS_SPACE(*(q - 1)) || *(q - 1) == ';') &&
- matchattr(q, "filename", 8, &name))
- path = name->ptr;
+ matchattr(q, "filename", 8, &name) &&
+ strlen(name->ptr) < 256)
+ path = name->ptr;
else if ((p = checkHeader(buf, "Content-Type:")) != NULL &&
(q = strcasestr(p, "name")) != NULL &&
(q == p || IS_SPACE(*(q - 1)) || *(q - 1) == ';') &&
- matchattr(q, "name", 4, &name))
+ matchattr(q, "name", 4, &name) &&
+ strlen(name->ptr) < 256)
path = name->ptr;
}
return guess_filename(path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment