diff mbox series

[cgi-io] main: allow underscore character in filename/mimetype

Message ID 20220811170432.21172-1-ptpt52@gmail.com
State New
Headers show
Series [cgi-io] main: allow underscore character in filename/mimetype | expand

Commit Message

Chen Minqiang Aug. 11, 2022, 5:04 p.m. UTC
From: Chen Minqiang <ptpt52@gmail.com>

This add underscore character to valid char list in filename or in
mimetype. It is not usual but should theoretically be valid.

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
---
 main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/main.c b/main.c
index 8ca4c04..9e715de 100644
--- a/main.c
+++ b/main.c
@@ -547,11 +547,11 @@  main_download(int argc, char **argv)
 		return failure(403, 0, "Requested path is not a regular file or block device");
 
 	for (p = fields[5]; p && *p; p++)
-		if (!isalnum(*p) && !strchr(" ()<>@,;:[]?.=%-", *p))
+		if (!isalnum(*p) && !strchr(" ()<>@,;:[]?.=%-_", *p))
 			return failure(400, 0, "Invalid characters in filename");
 
 	for (p = fields[7]; p && *p; p++)
-		if (!isalnum(*p) && !strchr(" .;=/-", *p))
+		if (!isalnum(*p) && !strchr(" .;=/-_", *p))
 			return failure(400, 0, "Invalid characters in mimetype");
 
 	rfd = open(fields[3], O_RDONLY);
@@ -745,11 +745,11 @@  main_exec(int argc, char **argv)
 		return failure(403, 0, "Exec permission denied");
 
 	for (p = fields[5]; p && *p; p++)
-		if (!isalnum(*p) && !strchr(" ()<>@,;:[]?.=%-", *p))
+		if (!isalnum(*p) && !strchr(" ()<>@,;:[]?.=%-_", *p))
 			return failure(400, 0, "Invalid characters in filename");
 
 	for (p = fields[7]; p && *p; p++)
-		if (!isalnum(*p) && !strchr(" .;=/-", *p))
+		if (!isalnum(*p) && !strchr(" .;=/-_", *p))
 			return failure(400, 0, "Invalid characters in mimetype");
 
 	args = fields[3] ? parse_command(fields[3]) : NULL;