Continued work on cgi interfaces.

This commit is contained in:
Brad Arant committed 2025-12-09 12:29:39 -08:00
1 parent ac0865d2da
commit 3bd9ea124f
3 files changed
+3 -54

No files matched your search

-51
View File
@@ -56,55 +56,4 @@ namespace jet {
}
}
void Global::setupFormData(coreutils::ZString &formdata) {
coreutils::ZString boundary = formdata.goeol();
while(!formdata.eod()) {
if(formdata.ifNext("Content-Disposition: form-data;")) {
formdata.skipWhitespace();
if(formdata.ifNext("name=\"")) {
coreutils::ZString name = formdata.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
if(formdata.ifNext("\"")) {
formdata.goeol();
formdata.goeol();
coreutils::ZString data = formdata.getTokenExclude("-"); // TODO: Fix this parsing. Need a string exclusion method to check for 'boundary'.
data.trimCRLF();
formdata.ifNext(boundary);
int index = 0;
coreutils::MString namex;
do {
namex = "";
namex << name << ":" << index++;
} while(cgiVariables.count(namex) != 0);
cgiVariables[namex] = data;
if(formdata.ifNext("--"))
break;
formdata.goeol();
}
else
throw coreutils::Exception("expecting closing double quote on variable name in received CGI data.");
} else
throw coreutils::Exception("expecting name subfield in received CGI data.");
} else
throw coreutils::Exception("expecting Content-Disposition header in received CGI data.");
}
}
void Global::setupFormURLEncoded(coreutils::ZString &formdata) {
while(!formdata.eod()) {
coreutils::ZString name = formdata.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
if(formdata.ifNext("=")) {
coreutils::MString data = formdata.getTokenExclude("&");
formdata.ifNext("&");
int index = 0;
coreutils::MString namex;
do {
namex = "";
namex << name << ":" << index++;
} while(cgiVariables.count(namex) != 0);
cgiVariables[namex] = data.fromCGI();
} else
throw coreutils::Exception("expecting = after name in received CGI data.");
}
}
}