From 72f37fd98983c49099f0d98ecef5a78a908e3e15 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 10 Dec 2010 17:08:54 +0100 Subject: [PATCH] Hunt for mime_parser bugs... - don't prepend the content-type/content-length - mime header if we don't intend to use it anyways. --- webcit/webcit.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/webcit/webcit.c b/webcit/webcit.c index 64b42ee0a..a23482421 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -482,23 +482,22 @@ void seconds_since_last_gexp(void) int ReadPostData(void) { int rc; - int body_start = 0; + int urlencoded_post = 0; wcsession *WCC = WC; StrBuf *content = NULL; + urlencoded_post = (strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33) == 0) ; + content = NewStrBufPlain(NULL, WCC->Hdr->HR.ContentLength + 256); - StrBufPrintf(content, + if (!urlencoded_post) + { + StrBufPrintf(content, "Content-type: %s\n" - "Content-length: %ld\n\n", - ChrPtr(WCC->Hdr->HR.ContentType), + "Content-length: %ld\n\n", + ChrPtr(WCC->Hdr->HR.ContentType), WCC->Hdr->HR.ContentLength); -/* - hprintf("Content-type: %s\n" - "Content-length: %d\n\n", - ContentType, ContentLength); -*/ - body_start = StrLength(content); + } /** Read the entire input data at once. */ rc = client_read_to(WCC->Hdr, content, @@ -508,8 +507,7 @@ int ReadPostData(void) return rc; - if (!strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33)) { - StrBufCutLeft(content, body_start); + if (urlencoded_post) { ParseURLParams(content); } else if (!strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "multipart", 9)) { char *Buf; -- 2.39.2