allow cookie, header and stream only in cgi mode.

This commit is contained in:
Brad Arant 2025-01-15 14:51:15 -08:00
parent 8b49bf39a9
commit edebae34b1
9 changed files with 30 additions and 12 deletions

View File

@ -31,6 +31,7 @@ namespace jet {
std::map<coreutils::MString, coreutils::MString> headers;
std::map<coreutils::MString, coreutils::MString> tags;
char **envp;
bool cgi = false;
};

View File

@ -1,9 +1,7 @@
1) Allow keyword variables to be resolved with a ';resolve' modifier.
2) Only allow stream tag in CGI mode.
3) Create a method to upload a file directly to a file name to bypass
buffering on large files.
4) Allow the cookie tag only if CGI mode selected.
5) Call tag is acting wierd. Look at testcall.jet.
6) Create a tag for uploading of URL data to a specific file instead
of buffering in an internal variable. Use <upload />. See testcgi.jet

View File

@ -8,6 +8,8 @@ namespace jet {
__cookie::__cookie(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
output = false;
if(!global.cgi)
throw coreutils::Exception("must enable cgi mode on jet tag to use cookie tag.");
if(!keywordDefined("name"))
throw coreutils::Exception("header tag must have name defined.");
if(!keywordDefined("expr") && keywordDefined("value") && hasContainer)

View File

@ -11,21 +11,24 @@ namespace jet {
std::ofstream outFile(keywords["file"].str());
if(global.cgi) {
outFile << "*** CGI VARIABLES ***" << std::endl;
for (auto i = global.cgiVariables.begin(); i != global.cgiVariables.end(); i++)
outFile << i->first << "=[" << i->second << "]" << std::endl;
}
outFile << "*** GLOBAL VARIABLES ***" << std::endl;
for (auto i = global.variables.begin(); i != global.variables.end(); i++)
outFile << i->first << "=[" << i->second << "]" << std::endl;
outFile << "*** LOCAL VARIABLES ***" << std::endl;
for (auto i = local->variables.begin(); i != local->variables.end(); i++)
outFile << i->first << "=[" << i->second << "]" << std::endl;
outFile << "*** KEYWORD VALUES ***" << std::endl;
for (auto i = parent->keywords.begin(); i != parent->keywords.end(); i++)
outFile << i->first << "=[" << i->second << "]" << std::endl;
outFile.close();
}

View File

@ -7,6 +7,8 @@ namespace jet {
__header::__header(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
output = false;
if(!global.cgi)
throw coreutils::Exception("must enable cgi mode on jet tag to use header tag.");
if(!keywordDefined("name"))
throw coreutils::Exception("header tag must have name defined.");
if(!keywordDefined("expr") && keywordDefined("value") && hasContainer)

View File

@ -7,6 +7,7 @@ namespace jet {
__jet::__jet(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
if(keywordDefined("cgi") && (keywords[resolveKeyword("cgi")] == "true")) {
global.cgi = true;
coreutils::ZString requestMethod(getenv("REQUEST_METHOD"));
if(requestMethod == "POST") {
coreutils::ZString contentLength(getenv("CONTENT_LENGTH"));

View File

@ -7,6 +7,8 @@ namespace jet {
__stream::__stream(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
output = false;
if(!global.cgi)
throw coreutils::Exception("must enable cgi mode on jet tag to use stream tag.");
if(!keywordDefined("name"))
throw coreutils::Exception("stream tag must have a file name to stream.");
global.outputHeaders();

View File

@ -1,4 +1,5 @@
#!../jet-2.0
<jet>
This is output
<stream name="test" />
</jet>

View File

@ -1,11 +1,19 @@
#!../jet-2.0
<jet filterblanklines="true" trimlines="true">
<tag name="testform">
<tag name="field">
<input name="field">
<container />
</input>
</tag>
<form>
<container />
</form>
</tag>
<testform>
zzz
<field>
xxx
</field>
</testform>
</jet>