- CGIFormData: fix broken setSize()+read() double-length bug that corrupted every parsed body with a leading run of garbage bytes (setSize(contentLength) pre-set length before read()/write() appended on top of it); switch content-type checks from exact equality to startsWith() since a real multipart Content-Type always carries a boundary= parameter; implement the previously empty multipart/form-data branch (ordinary fields only, file uploads deferred to a separate upload mechanism per TODO.txt); restore operator[] real lookup logic (was hardcoded to echo the key back); default-initialize formdata to NULL; fix mismatched include guard (leftover from an IMFFormData.h copy-paste); drop the unused IMFHeader.h include that pulled in a broken, unrelated StreamReader.h dependency. - CGIFormattedData: parameterize the split delimiter (was hardcoded to &, which silently broke cookie parsing since HTTP_COOKIE uses ; not &) and trim whitespace on each split token. - MString::toCGI()/fromCGI(): were unimplemented stubs (always returned an empty string); implemented proper CGI percent-encode / percent-decode + space plus-encoding, and fixed the one caller that discarded fromCGIs return value instead of using it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
37 lines
715 B
C++
37 lines
715 B
C++
#ifndef __CGIFormattedData_h__
|
|
# define __CGIFormattedData_h__
|
|
|
|
# include "MString.h"
|
|
# include <map>
|
|
|
|
namespace coreutils {
|
|
|
|
///
|
|
/// Use the CGIFormattedData object to store and process data that
|
|
/// interfaces to the CGI format. Value pairs are accessible using
|
|
/// a common map interface.
|
|
///
|
|
|
|
class CGIFormattedData {
|
|
|
|
public:
|
|
CGIFormattedData();
|
|
CGIFormattedData(ZString cgiData);
|
|
CGIFormattedData(ZString cgiData, ZString delimiter);
|
|
|
|
ZString operator=(ZString cgiData);
|
|
void setDelimiter(ZString delimiter);
|
|
|
|
std::map<MString, MString> data;
|
|
|
|
private:
|
|
void parse(ZString cgiData);
|
|
|
|
ZString delimiter = "&";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|