Files
JetCore/Global.h
T
Brad ArantandClaude Sonnet 5 2d9505cd33 Fix jet cgi=yes CGI variable loading and related bugs
- __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>
2026-08-22 21:37:51 -07:00

46 lines
1.2 KiB
C++

#ifndef __Global_h__
# define __Global_h__
# include "MString.h"
# include "CGIFormattedData.h"
# include "CGIFormData.h"
# include <map>
namespace jet {
class __mysql;
class Global {
public:
Global(char **envp);
virtual ~Global();
void dump();
bool sessionExists(coreutils::MString sessionId);
void addSession(coreutils::MString sessionId, __mysql *mysql);
void removeSession(coreutils::MString sessionId);
__mysql * getSession(coreutils::MString sessionId);
coreutils::ZString getSessionVariable(coreutils::MString &splitName);
void outputHeaders();
void setupFormData(coreutils::ZString &formdata);
void setupFormURLEncoded(coreutils::ZString &formdata);
char *errorCursor = NULL;
coreutils::CGIFormattedData cookies;
coreutils::CGIFormData *cgiData = NULL;
std::map<coreutils::MString, coreutils::MString> variables;
std::map<coreutils::MString, __mysql *> sessions;
std::map<coreutils::MString, coreutils::MString> headers;
std::map<coreutils::MString, coreutils::MString> tags;
char **envp;
bool cgi = false;
bool session = false;
coreutils::MString sessionId;
};
}
#endif