- __jet.cpp: the cgi keyword check compared against "true" but the
documented/intended value is "yes", so <jet cgi="yes" ...> never
actually turned CGI mode on; fixed. Also replaced the hardcoded
fake multipart boundary ("xxxx") with real extraction from the
Content-Type header's boundary= parameter.
- Global.h: default-initialize cgiData to NULL (a GET request with
cgi="yes" never allocates it, so it was previously left
dangling); Global.cpp now sets the cookie jar's delimiter to ";"
to match RFC 6265, since it defaulted to CGIFormattedData's
&-based form-data delimiter.
- Global.cpp: fix addSession()'s missing throw that let it silently
continue past a duplicate session id.
- Tag.cpp: fix the CGI-variable lookup branch, which failed to
compile (cgiData is a pointer; needed to dereference it before
indexing) and added a null check so a CGI request that never
populated cgiData (bad Content-Type, or the null-safety gap
above) throws a clear error instead of crashing; implemented the
previously-empty session-variable lookup branch; left the
unreachable duplicate environment-variable branch as-is with a
comment, since fixing its sigil is a user-facing template-syntax
decision, not a bug fix.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
50 lines
1.7 KiB
C++
50 lines
1.7 KiB
C++
#include "__jet.h"
|
|
#include "Exception.h"
|
|
#include "Global.h"
|
|
#include "SessionId.h"
|
|
#include <stdlib.h>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
|
|
namespace jet {
|
|
|
|
__jet::__jet(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
|
|
char *cookies;
|
|
if(keywordDefined("cgi") && (resolveKeyword("cgi") == "yes")) {
|
|
global.cgi = true;
|
|
|
|
if(keywordDefined("sessiondir")) {
|
|
global.session = true;
|
|
global.cookies = getenv("HTTP_COOKIE");
|
|
if(global.cookies.data["session"] != NULL) {
|
|
// pull sessionfile from sessiondir.
|
|
// if last activity time is expired then ignore.
|
|
// follow sessiontimeoutredirecturl.
|
|
} else {
|
|
SessionId sessionId;
|
|
global.headers["Set-Cookie"] << "session=" << sessionId;
|
|
global.cookies.data["session"] = sessionId;
|
|
if(keywordDefined("sessiontimeout")) {
|
|
time_t timeout = time(0) + keywords["sessiontimeout"].asInteger();
|
|
}
|
|
// also save last activity time in session file.
|
|
}
|
|
}
|
|
|
|
coreutils::ZString requestMethod(getenv("REQUEST_METHOD"));
|
|
if(requestMethod == "POST") {
|
|
coreutils::ZString contentLength(getenv("CONTENT_LENGTH"));
|
|
coreutils::ZString contentType(getenv("CONTENT_TYPE"));
|
|
coreutils::ZString boundary;
|
|
int boundaryPos = contentType.find("boundary=");
|
|
if(boundaryPos != -1) {
|
|
boundary = contentType.substring(boundaryPos + 9);
|
|
}
|
|
|
|
global.cgiData = new coreutils::CGIFormData(0, contentType, contentLength.asInteger(), boundary);
|
|
}
|
|
}
|
|
processContainer(container, NULL, true);
|
|
}
|
|
}
|