From ea616acdb7d5674fe08cfcfe05231d8fb2e0908b Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Fri, 8 Apr 2022 14:57:26 +0000 Subject: [PATCH] get_mime_boundary tests FossilOrigin-Name: 60c5397f0ca912546c789cb17ce2b5adf1196675417dc06f91b49ddcd1bfceb3 --- Makefile | 5 ++++- src/mime.c | 13 ++++++----- src/mime.h | 2 +- test/Makefile | 4 ++-- test/tests | Bin 15768 -> 25008 bytes test/unit/mime_multipart.c | 44 +++++++++++++++++++++---------------- 6 files changed, 40 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 0050955..e6f4f18 100644 --- a/Makefile +++ b/Makefile @@ -96,6 +96,9 @@ install: $(TARGET) install -d $(PREFIX)/share/treebird/ cp -r dist/ $(PREFIX)/share/treebird/ +test: + make -C test + apache_start: ./scripts/fcgistarter.sh @@ -119,4 +122,4 @@ clean_deps: clean_all: clean clean_deps -.PHONY: all filec clean update clean clean_deps clean_all +.PHONY: all filec clean update clean clean_deps clean_all test diff --git a/src/mime.c b/src/mime.c index 701fc89..0d9a6b2 100644 --- a/src/mime.c +++ b/src/mime.c @@ -22,17 +22,18 @@ #include #include "mime.h" -char* get_mime_boundary() +char* get_mime_boundary(char* content_type_str, char** bound) { - if (!getenv("CONTENT_TYPE")) return 1; + char* content = content_type_str ? content_type_str : getenv("CONTENT_TYPE"); // Data gets changed in place - char* content_type = malloc(strlen(getenv("CONTENT_TYPE"))+1); + char* content_type = malloc(strlen(content)+1); if (!content_type) { perror("malloc"); exit(1); } + strcpy(content_type, content); char* bound_str; char* boundary; @@ -55,10 +56,12 @@ char* get_mime_boundary() if ((tmp = strchr(boundary, '\"'))) *tmp = '\0'; - return 0; + *bound = boundary; + + return content_type; error: free(content_type); - return 1; + return NULL; } char* strnws(char* str) diff --git a/src/mime.h b/src/mime.h index 6416766..631d79c 100644 --- a/src/mime.h +++ b/src/mime.h @@ -19,7 +19,7 @@ #ifndef MIME_H #define MIME_H -char* get_mime_boundary(); +char* get_mime_boundary(char* content_type, char** res); char* read_mime_data(char* boundary, char* begin, struct http_form_info* info); #endif /* MIME_H */ diff --git a/test/Makefile b/test/Makefile index b51a52b..17c96e3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,10 +1,10 @@ CC ?= cc MASTODONT_DIR = mastodont-c/ MASTODONT = $(MASTODONT_DIR)libmastodont.a -CFLAGS += -Wall -I ../$(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-discarded-qualifiers -I/usr/include/ $(shell pkg-config --cflags libcurl libcjson libpcre) +CFLAGS += -g -Wall -I ../$(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-discarded-qualifiers -I/usr/include/ $(shell pkg-config --cflags libcurl libcjson libpcre) LDFLAGS = -L./../$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcjson libcurl libpcre) -lfcgi TARGET = tests -SRC = unit/main.c +SRC = unit/main.c ../src/mime.c OBJ = $(patsubst %.c,%.o,$(SRC)) all: $(TARGET) diff --git a/test/tests b/test/tests index 4e2bbbb220ddf8b797e649e30fadad39bf7bf2b5..d3d1a981f62b03884577ca6b664f5c9c9d9c99a7 100755 GIT binary patch literal 25008 zcmeHP4Rl-8eZNmnPkOdwS+?^@0#QPe28!j6Bqkv^v7I=`!3kO7l%y1dEXlTrEV0q9`s zm=D+G>{8|d?&dVX?+^f7k%nBw(3Er?kn|pu{8G4B$|Jqicuos@bfrJjNz z87~D@Jjo6E`-bF~!Y$xYQjlaR?R?QnP`-B=M`yrOE3fw)$WSP+*|CRxWvT0pmrq8G z`Au zx)`)j8F~`5a`Hzj&~K?g|5OF~nF@5OUkHDt>1QC6^XFIv`W2vu@K>5X2SPbJyDHG{ zt3ZFO0{yQl&~p{&&s3n_RDr&=0{s-|@)kkPk)l0)+oOqOE;*RWTghDC_RZ;RCfOJ3 zPbXP4IyjuoMDtcGXGNooiT|HumvC2VLV>!{A z9d!PjBqGwf4h|UE7vrM9I~;WR$mNWPgI+B}`E{p*?sw4l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;~93H(NQYHK& znTZMbQD2-*-hHz-e+PG|6j9=ud7-4%e~jc z{`|Yeat~Dg2LI9AKCfFCw~!;RW9;qk20Q*%F`w5pjI+eYS^H0FaSSS$Q|9x! zigA`4xqbWbKSTU3^5b+im71;JD&mq+D`i_@1PIB{Jgw5S|O%AO8JC9rxWr7n6^e(l@yw XGTKB~6EDqgz}E$#;CkI!Y@+xl5u=Gu diff --git a/test/unit/mime_multipart.c b/test/unit/mime_multipart.c index 4ac91d0..248c666 100644 --- a/test/unit/mime_multipart.c +++ b/test/unit/mime_multipart.c @@ -1,29 +1,35 @@ -#include "../mine.h" -#define BOUNDARY_CONTENT_T1 "Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266" -#define BOUNDARY_CONTENT_T2 "Content-Type: multipart/form-data; boundary=\"---------------------------9051914041544843365972754266\"" +#include "../../src/mime.h" +#define BOUNDARY_CONTENT_T1 "multipart/form-data; boundary=---------------------------9051914041544843365972754266" +#define BOUNDARY_CONTENT_T2 "multipart/form-data; boundary=\"---------------------------9051914041544843365972754266\"" #define BOUNDARY_RES_T "---------------------------9051914041544843365972754266" -#define MULTIPART_TEST "-----------------------------9051914041544843365972754266\r\n" -"Content-Disposition: form-data; name=\"text\"\r\n\r\n" - -"text default\r\n" -"-----------------------------9051914041544843365972754266\r\n" -"Content-Disposition: form-data; name=\"file1\"; filename=\"a.txt\"\r\n" -"Content-Type: text/plain\r\n\r\n" - -"Content of a.txt.\r\n\r\n" - -"-----------------------------9051914041544843365972754266\r\n" -"Content-Disposition: form-data; name=\"file2\"; filename\"a.html\"\r\n" -"Content-Type: text/html\r\n\r\n" - -"Content of a.html.\r\n\r\n" - +#define MULTIPART_TEST "-----------------------------9051914041544843365972754266\r\n" \ +"Content-Disposition: form-data; name=\"text\"\r\n\r\n" \ +"text default\r\n" \ +"-----------------------------9051914041544843365972754266\r\n" \ +"Content-Disposition: form-data; name=\"file1\"; filename=\"a.txt\"\r\n" \ +"Content-Type: text/plain\r\n\r\n" \ +"Content of a.txt.\r\n\r\n" \ +"-----------------------------9051914041544843365972754266\r\n" \ +"Content-Disposition: form-data; name=\"file2\"; filename\"a.html\"\r\n" \ +"Content-Type: text/html\r\n\r\n" \ +"Content of a.html.\r\n\r\n" \ "-----------------------------9051914041544843365972754266--" +#include +#include int mime_multipart_test(void) { + char* bound, *bound2; + char* mem = get_mime_boundary(BOUNDARY_CONTENT_T2, &bound); + char* mem2 = get_mime_boundary(BOUNDARY_CONTENT_T1, &bound2); + assert(bound != NULL && bound2 != NULL); + assert(strcmp(bound, BOUNDARY_RES_T) == 0 && + strcmp(bound2, BOUNDARY_RES_T) == 0); + free(mem); + free(mem2); + return 0; }