Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2847ce5fa7 | ||
|
|
fd81bb877f | ||
|
|
cfdb3cbf57 | ||
|
|
3c6411c16e | ||
|
|
a18d1358b0 | ||
|
|
9fae14eb96 | ||
|
|
ec3e40b71a | ||
|
|
5f9a53aba2 | ||
|
|
fdcb2b43a9 | ||
|
|
08462ca996 | ||
|
|
867ace3cb3 | ||
|
|
b8f7793773 | ||
|
|
905fbafa5a | ||
|
|
9d965bfd1a | ||
|
|
46ef67b735 | ||
|
|
41fbf0b7d9 | ||
|
|
dcfe2a667c | ||
|
|
c1491b044b | ||
|
|
b0cadc3f08 | ||
|
|
54b6e522f9 | ||
|
|
7893746582 | ||
|
|
b276bdb6cc | ||
|
|
7f6ebb0ea8 | ||
|
|
8b2391b289 | ||
|
|
5c703f5620 | ||
|
|
97142ce9b4 | ||
|
|
9f3349b671 | ||
|
|
8483618012 | ||
|
|
a7dab09150 | ||
|
|
76ea89e79c | ||
|
|
bc3c50f045 | ||
|
|
942d2641ab | ||
|
|
fde94acad6 | ||
|
|
b143b821de | ||
|
|
80a939d1ef | ||
|
|
7b4a25f305 | ||
|
|
b1c275182a | ||
|
|
9bbb95cc57 | ||
|
|
3f273b0a95 | ||
|
|
634eb7a9a9 | ||
|
|
a32444acc2 | ||
|
|
6ac33601a0 | ||
|
|
aaed4cb4da | ||
|
|
f33c041ae5 | ||
|
|
a94fc5e8fb | ||
|
|
d52ca61250 | ||
|
|
fc849c44a4 | ||
|
|
6f2f3d7339 | ||
|
|
51133e0c76 | ||
|
|
2d9505cd33 | ||
|
|
d0f2551e89 | ||
|
|
e6ebb34366 | ||
|
|
3bd9ea124f | ||
|
|
ac0865d2da | ||
|
|
7e835e5073 | ||
|
|
8b38617b00 | ||
|
|
50a29a4238 | ||
|
|
db59e9e87c | ||
|
|
3f14b28435 | ||
|
|
a91d78f524 | ||
|
|
61216a2296 | ||
|
|
63916cc32a | ||
|
|
5e0523619d | ||
|
|
3314a410e0 | ||
|
|
c21f27f14d | ||
|
|
4e47d6aaf7 | ||
|
|
e6bee9b67b | ||
|
|
6e25db1e44 | ||
|
|
c4f0fab8c7 | ||
|
|
96302e1d27 | ||
|
|
bdbae9e397 | ||
|
|
078a73664c | ||
|
|
280d4b8aa2 | ||
|
|
7b6342b8d7 | ||
|
|
94c8833f2a | ||
|
|
0cb8a08a73 | ||
|
|
2f30b3f8c4 |
No files matched your search
@@ -1,4 +1,39 @@
|
||||
*.o
|
||||
*~
|
||||
jet-2.0
|
||||
docs/JetCore.aux
|
||||
docs/JetCore.dvi
|
||||
docs/JetCore.log
|
||||
docs/JetCore.toc
|
||||
|
||||
# jetc build byproducts (compiled JET-to-C++ output, binaries, .jtc/.a artifacts).
|
||||
# Generated .cpp files are always named "*.compiled.cpp" (see build-compiled.sh/
|
||||
# build-shared.sh) - deliberately not a blanket "*.cpp", which would also
|
||||
# swallow real source files added to jetc/ later (bit us once already: an
|
||||
# earlier blanket rule silently hid api_test.cpp from git status).
|
||||
jetc/jetc
|
||||
jetc/demo
|
||||
jetc/demo2
|
||||
jetc/demo3
|
||||
jetc/host_test
|
||||
jetc/api_test
|
||||
jetc/demo.cpp
|
||||
jetc/demo2.cpp
|
||||
jetc/demo4
|
||||
jetc/demo5
|
||||
jetc/demo6
|
||||
jetc/demo7
|
||||
jetc/*.compiled.cpp
|
||||
jetc/*.pic.o
|
||||
jetc/*.jtc
|
||||
jetc/libCoreUtils_pic.a
|
||||
|
||||
# These 3 pages' converted output bakes in a real barant.com DB password
|
||||
# (via BARANT_DB_PASSWORD at conversion time - see convert.py's MYSQL_PAGES
|
||||
# handling) so they never enter git history, unlike the rest of
|
||||
# jetc/barant-site/jet/, which is plain static content and safe to commit.
|
||||
jetc/barant-site/jet/vst.jet
|
||||
jetc/barant-site/jet/modular1.jet
|
||||
jetc/barant-site/jet/modular1_patches.jet
|
||||
jetc/**/*.jtc
|
||||
jetc/__pycache__/
|
||||
@@ -3,7 +3,8 @@
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
"${workspaceFolder}/**",
|
||||
"${workspaceFolder}/../CoreUtils/**"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
#include "Global.h"
|
||||
#include "Exception.h"
|
||||
#include "__mysql.h"
|
||||
#include "__imap.h"
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
|
||||
namespace jet {
|
||||
|
||||
Global::Global(char **envp) : envp(envp) {
|
||||
|
||||
cookies.setDelimiter(";");
|
||||
}
|
||||
|
||||
Global::~Global() {
|
||||
|
||||
// JFile's destructor (via MFile::~MFile()->update()) is what actually
|
||||
// writes the session JSON back to disk - it has to run for session
|
||||
// persistence to happen at all, so sessionFile can't be left as a
|
||||
// leaked, never-deleted pointer the way cgiData currently is.
|
||||
if(sessionFile)
|
||||
delete sessionFile;
|
||||
}
|
||||
|
||||
void Global::dump() {
|
||||
@@ -25,7 +32,7 @@ namespace jet {
|
||||
|
||||
void Global::addSession(coreutils::MString sessionId, __mysql *mysql) {
|
||||
if(sessionExists(sessionId))
|
||||
coreutils::Exception("sessionid already exists.");
|
||||
throw coreutils::Exception("sessionid already exists.");
|
||||
sessions[sessionId] = mysql;
|
||||
}
|
||||
|
||||
@@ -39,6 +46,26 @@ namespace jet {
|
||||
return sessions[sessionId];
|
||||
}
|
||||
|
||||
bool Global::imapSessionExists(coreutils::MString sessionId) {
|
||||
return imapSessions.find(sessionId) != imapSessions.end();
|
||||
}
|
||||
|
||||
void Global::addImapSession(coreutils::MString sessionId, __imap *imap) {
|
||||
if(imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid already exists.");
|
||||
imapSessions[sessionId] = imap;
|
||||
}
|
||||
|
||||
void Global::removeImapSession(coreutils::MString sessionId) {
|
||||
imapSessions.erase(sessionId);
|
||||
}
|
||||
|
||||
__imap * Global::getImapSession(coreutils::MString sessionId) {
|
||||
if(imapSessions.find(sessionId) == imapSessions.end())
|
||||
throw coreutils::Exception("requested imap session is not available.");
|
||||
return imapSessions[sessionId];
|
||||
}
|
||||
|
||||
coreutils::ZString Global::getSessionVariable(coreutils::MString &splitName) {
|
||||
if(sessions.find(splitName[0]) == sessions.end())
|
||||
throw coreutils::Exception("requested session is not available in variable.");
|
||||
@@ -56,55 +83,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.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,16 @@
|
||||
|
||||
# include "MString.h"
|
||||
# include "CGIFormattedData.h"
|
||||
# include "CGIFormData.h"
|
||||
# include "StreamReader.h"
|
||||
# include "JFile.h"
|
||||
# include <map>
|
||||
|
||||
namespace jet {
|
||||
|
||||
class __mysql;
|
||||
class __imap;
|
||||
class Tag;
|
||||
|
||||
class Global {
|
||||
|
||||
@@ -20,6 +25,10 @@ namespace jet {
|
||||
void addSession(coreutils::MString sessionId, __mysql *mysql);
|
||||
void removeSession(coreutils::MString sessionId);
|
||||
__mysql * getSession(coreutils::MString sessionId);
|
||||
bool imapSessionExists(coreutils::MString sessionId);
|
||||
void addImapSession(coreutils::MString sessionId, __imap *imap);
|
||||
void removeImapSession(coreutils::MString sessionId);
|
||||
__imap * getImapSession(coreutils::MString sessionId);
|
||||
coreutils::ZString getSessionVariable(coreutils::MString &splitName);
|
||||
void outputHeaders();
|
||||
void setupFormData(coreutils::ZString &formdata);
|
||||
@@ -27,16 +36,58 @@ namespace jet {
|
||||
char *errorCursor = NULL;
|
||||
|
||||
coreutils::CGIFormattedData cookies;
|
||||
|
||||
///
|
||||
/// cgiReader backs cgiData below - it must outlive it, since
|
||||
/// CGIFormData (a Parser) only holds a reference to it, not its own
|
||||
/// copy of the request body. Declared before cgiData so it's
|
||||
/// constructed first and destroyed last (member destruction order
|
||||
/// mirrors declaration order).
|
||||
///
|
||||
|
||||
coreutils::StreamReader cgiReader;
|
||||
coreutils::CGIFormData *cgiData = NULL;
|
||||
|
||||
///
|
||||
/// sessionFile backs $[@name] (read) and <set name="@name" .../>
|
||||
/// (write) - a JSON file at sessiondir/<sessionId>.json, loaded when
|
||||
/// opened and saved automatically when destroyed (JFile/MFile's own
|
||||
/// RAII behavior - see MFile.cpp). NULL unless cgi mode and the
|
||||
/// sessiondir keyword are both active for this request.
|
||||
///
|
||||
|
||||
coreutils::JFile *sessionFile = NULL;
|
||||
std::map<coreutils::MString, coreutils::MString> variables;
|
||||
std::map<coreutils::MString, coreutils::MString> cgiVariables;
|
||||
std::map<coreutils::MString, __mysql *> sessions;
|
||||
std::map<coreutils::MString, coreutils::MString> headers;
|
||||
std::map<coreutils::MString, coreutils::MString> tags;
|
||||
|
||||
// Populated once per compiled .jtc module's own entry function (see
|
||||
// jetc's TAGDEF codegen) - a top-level <tag name="X"> definition
|
||||
// that jetc could compile directly registers its own render
|
||||
// function here under its lowercase name, same key convention as
|
||||
// `tags` above. __dotag checks this first before falling back to
|
||||
// the text-based findTagDefinition()/processContainer() path (see
|
||||
// __dotag.cpp), avoiding a full re-parse of the definition's body
|
||||
// on every invocation. A miss here (a locally-scoped/nested tag
|
||||
// definition, or content that was never compiled at all) is always
|
||||
// safe - it just means the existing interpreted path runs exactly
|
||||
// as it always has; this is a pure additive fast path, never a
|
||||
// replacement for `tags`, which every TAGDEF still populates too.
|
||||
std::map<coreutils::MString, void(*)(Tag&, coreutils::MString&)> compiledTags;
|
||||
|
||||
char **envp;
|
||||
bool cgi = false;
|
||||
bool session = false;
|
||||
coreutils::MString sessionId;
|
||||
|
||||
// Deliberately the LAST member declared in Global - appended
|
||||
// here, after every pre-existing field, rather than inserted
|
||||
// earlier among them, so this addition does not shift the
|
||||
// memory offset of any field that existed before it. See
|
||||
// __imap.h for what registers here.
|
||||
std::map<coreutils::MString, __imap *> imapSessions;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
#include "Exception.h"
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <time.h>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
||||
namespace jet {
|
||||
|
||||
Operand::Operand(coreutils::ZString &in, Tag &tag) {
|
||||
Operand::Operand(coreutils::ZString &in, Tag &tag, bool stop) : in(in), tag(tag) {
|
||||
|
||||
doubleValue = 0;
|
||||
|
||||
@@ -18,13 +23,79 @@ namespace jet {
|
||||
isNumber = string.eod();
|
||||
string.reset();
|
||||
if((string == "false") || (string == "true"))
|
||||
boolean = true;
|
||||
boolean = (string == "true");
|
||||
} else if(in.ifNext("(")) {
|
||||
Operand op(in, tag);
|
||||
string = op.string;
|
||||
doubleValue = op.doubleValue;
|
||||
isNumber = op.isNumber;
|
||||
// A parenthesized sub-expression's own comparison result was never
|
||||
// propagated to the wrapping Operand - only string/doubleValue/
|
||||
// isNumber were copied, leaving this Operand's own `boolean`
|
||||
// genuinely uninitialized (Operand.h declares it with no default
|
||||
// value). Confirmed via debug tracing: printed as garbage stack
|
||||
// bytes, which "and"/"or" then combined instead of the real
|
||||
// true/false result.
|
||||
boolean = op.boolean;
|
||||
if(!in.ifNext(")"))
|
||||
throw coreutils::Exception("expected ) in expression.");
|
||||
} else if(in.ifNextIgnoreCase("SUBSTRING_INDEX")) {
|
||||
// MySQL SUBSTRING_INDEX(str, delim, count): with a positive count,
|
||||
// returns everything before the count-th occurrence of delim
|
||||
// (counting from the left); with a negative count, everything
|
||||
// after the |count|-th occurrence (counting from the right). If
|
||||
// delim doesn't occur that many times, the whole string is
|
||||
// returned unchanged. Genuinely missing (like LOCATE was) - real
|
||||
// content (index2.cgi's own URI-parsing logic, ported as part of
|
||||
// the /var/www/barant jet-2.0 conversion) relies on it to peel a
|
||||
// path apart one segment at a time:
|
||||
// substring_index(substring_index('$[REQUEST_URI]','?',1),'/',2).
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for SUBSTRING_INDEX parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in SUBSTRING_INDEX expression.");
|
||||
Operand parm2(in, tag);
|
||||
if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in SUBSTRING_INDEX expression.");
|
||||
Operand parm3(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
coreutils::MString haystack = parm1.string;
|
||||
haystack.reset();
|
||||
coreutils::MString delim = parm2.string;
|
||||
delim.reset();
|
||||
int count = parm3.string.asInteger();
|
||||
int delimLen = (int)delim.getLength();
|
||||
std::vector<int> positions;
|
||||
if(delimLen > 0) {
|
||||
int base = 0;
|
||||
while(true) {
|
||||
coreutils::MString scan = haystack.substring(base);
|
||||
scan.reset();
|
||||
int pos = scan.find(delim);
|
||||
if(pos == -1) break;
|
||||
positions.push_back(base + pos);
|
||||
base += pos + delimLen;
|
||||
}
|
||||
}
|
||||
if(count >= 0) {
|
||||
size_t n = (size_t)count;
|
||||
if(n == 0 || positions.size() < n) {
|
||||
string = haystack.substring(0);
|
||||
} else {
|
||||
string = haystack.substring(0, positions[n - 1]);
|
||||
}
|
||||
} else {
|
||||
size_t n = (size_t)(-count);
|
||||
if(positions.size() < n) {
|
||||
string = haystack.substring(0);
|
||||
} else {
|
||||
int idx = positions[positions.size() - n];
|
||||
string = haystack.substring(idx + delimLen);
|
||||
}
|
||||
}
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of SUBSTRING_INDEX expression.");
|
||||
} else if(in.ifNextIgnoreCase("SUBSTRING")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for SUBSTRING parameters.");
|
||||
@@ -34,13 +105,78 @@ namespace jet {
|
||||
Operand parm2(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
string = parm1.string.substring(parm2.string.asInteger());
|
||||
} else if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
|
||||
Operand parm3(in, tag);
|
||||
} else {
|
||||
// Real, pre-existing bug fixed here: the 3-arg-only branch below
|
||||
// used to run unconditionally (missing braces around this
|
||||
// else-if), so even after the 2-arg form above already
|
||||
// succeeded, it fell through into trying to parse a third
|
||||
// argument from whatever was left (nothing, since the closing
|
||||
// ")" was already consumed) - always throwing "operand is not
|
||||
// valid." right after computing the correct 2-arg result.
|
||||
// Confirmed via real debug tracing showing an extra Operand
|
||||
// constructed on empty input immediately after a successful
|
||||
// 2-arg substring(str, start) call - the 2-arg form was
|
||||
// completely unusable before this fix.
|
||||
if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
|
||||
Operand parm3(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
string = parm1.string.substring(parm2.string.asInteger(), parm3.string.asInteger());
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of substring expression.");
|
||||
}
|
||||
} else if(in.ifNextIgnoreCase("LOCATE")) {
|
||||
// MySQL-style LOCATE(needle, haystack): 1-based position of the
|
||||
// first occurrence of needle within haystack, or 0 if not found -
|
||||
// a genuinely missing function (like <eval> was a genuinely
|
||||
// missing tag). Real 1.4 content depends on it for exactly this
|
||||
// "is #[name] present in the space-padded $[errfield] list"
|
||||
// pattern (barant.tag's own <field> definition:
|
||||
// locate(' #[name] ','$[errfield]') != 0), used throughout for
|
||||
// marking a field's input as erroring after a failed validation.
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for LOCATE parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in LOCATE expression.");
|
||||
Operand parm2(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
string = parm1.string.substring(parm2.string.asInteger(), parm3.string.asInteger());
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of substring expression.");
|
||||
coreutils::MString haystack = parm2.string;
|
||||
haystack.reset();
|
||||
int pos = haystack.find(parm1.string);
|
||||
doubleValue = (pos == -1) ? 0 : (pos + 1);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else {
|
||||
// Optional 3rd start_pos argument (MySQL LOCATE(substr, str,
|
||||
// pos)): search begins at the given 1-based position instead of
|
||||
// the start of the string. Needed by index2.cgi's own real
|
||||
// URI-parsing logic (walking a path one '/' at a time), ported
|
||||
// as part of the /var/www/barant jet-2.0 conversion.
|
||||
if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in LOCATE expression.");
|
||||
Operand parm3(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
coreutils::MString haystack = parm2.string;
|
||||
haystack.reset();
|
||||
int totalLen = (int)haystack.getLength();
|
||||
int startPos = parm3.string.asInteger() - 1;
|
||||
if(startPos < 0) startPos = 0;
|
||||
if(startPos >= totalLen) {
|
||||
doubleValue = 0;
|
||||
} else {
|
||||
coreutils::MString sub = haystack.substring(startPos);
|
||||
sub.reset();
|
||||
int pos = sub.find(parm1.string);
|
||||
doubleValue = (pos == -1) ? 0 : (startPos + pos + 1);
|
||||
}
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of LOCATE expression.");
|
||||
}
|
||||
} else if(in.ifNextIgnoreCase("LEFT")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for LEFT parameters.");
|
||||
@@ -60,6 +196,11 @@ namespace jet {
|
||||
Operand op(parm1.string, tag);
|
||||
string = op.string;
|
||||
isNumber = op.isNumber;
|
||||
if(isNumber) {
|
||||
doubleValue = op.doubleValue;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
}
|
||||
boolean = op.boolean;
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of EXPR expression.");
|
||||
@@ -85,6 +226,36 @@ namespace jet {
|
||||
string = parm1.string.trim();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of TRIM expression.");
|
||||
} else if(in.ifNextIgnoreCase("LTRIM")) {
|
||||
// Leading blanks only - the same characters TRIM removes (space,
|
||||
// tab, newline).
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for LTRIM parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
const char *data = parm1.string.getData();
|
||||
int len = parm1.string.getLength();
|
||||
int start = 0;
|
||||
while((start < len) && ((data[start] == ' ') || (data[start] == '\t') || (data[start] == '\n')))
|
||||
++start;
|
||||
string = parm1.string.substring(start, len - start);
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of LTRIM expression.");
|
||||
} else if(in.ifNextIgnoreCase("RTRIM")) {
|
||||
// Trailing blanks only. Counted by index rather than with
|
||||
// trimTrailingWhitespace(), which stops one character short and
|
||||
// would leave " " for an all-blank value.
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for RTRIM parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
const char *data = parm1.string.getData();
|
||||
int len = parm1.string.getLength();
|
||||
while((len > 0) && ((data[len - 1] == ' ') || (data[len - 1] == '\t') || (data[len - 1] == '\n')))
|
||||
--len;
|
||||
string = parm1.string.substring(0, len);
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of RTRIM expression.");
|
||||
} else if(in.ifNextIgnoreCase("TOUPPER")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for TOUPPER parameters.");
|
||||
@@ -102,9 +273,26 @@ namespace jet {
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of TOLOWER expression.");
|
||||
} else if(in.ifNextIgnoreCase("REVERSE")) {
|
||||
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for REVERSE parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
std::string reversed = parm1.string.str();
|
||||
std::reverse(reversed.begin(), reversed.end());
|
||||
string = reversed;
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of REVERSE expression.");
|
||||
} else if(in.ifNextIgnoreCase("CONCAT")) {
|
||||
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for CONCAT parameters.");
|
||||
Operand parm1(in, tag);
|
||||
string = parm1.string;
|
||||
while(in.ifNext(",")) {
|
||||
Operand parm(in, tag);
|
||||
string << parm.string;
|
||||
}
|
||||
if(!in.ifNext(")"))
|
||||
throw coreutils::Exception("Expecting ) at end of CONCAT expression.");
|
||||
} else if(in.ifNextIgnoreCase("INTEGER")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for INTEGER parameters.");
|
||||
@@ -114,13 +302,335 @@ namespace jet {
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of INTEGER expression.");
|
||||
} else if(in.ifNextIgnoreCase("ROUND")) {
|
||||
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for ROUND parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = round(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of ROUND expression.");
|
||||
} else if(in.ifNextIgnoreCase("RANDOM")) {
|
||||
unsigned int seed = (unsigned int)clock();
|
||||
doubleValue = (double) rand_r(&seed) / (RAND_MAX + 1.0);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else if(in.ifNextIgnoreCase("ABS")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for ABS parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = abs(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of ABS expression.");
|
||||
} else if(in.ifNextIgnoreCase("MAX")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for MAX parameters.");
|
||||
Operand *parm = new Operand(in, tag);
|
||||
string = parm->string;
|
||||
doubleValue = parm->doubleValue;
|
||||
isNumber = parm->isNumber;
|
||||
delete parm;
|
||||
while(in.ifNext(",")) {
|
||||
parm = new Operand(in, tag);
|
||||
if(isNumber != parm->isNumber)
|
||||
throw coreutils::Exception("All parameters in MAX expression must be same type.");
|
||||
if(isNumber) {
|
||||
if(parm->doubleValue > doubleValue) {
|
||||
doubleValue = parm->doubleValue;
|
||||
string = parm->string;
|
||||
}
|
||||
} else {
|
||||
if(parm->string > string) {
|
||||
doubleValue = parm->doubleValue;
|
||||
string = parm->string;
|
||||
}
|
||||
}
|
||||
delete parm;
|
||||
}
|
||||
if(!in.ifNext(")")) {
|
||||
throw coreutils::Exception("Expecting ) at end of MAX expression.");
|
||||
}
|
||||
string.removeTrailingZeros();
|
||||
} else if(in.ifNextIgnoreCase("MIN")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for MIN parameters.");
|
||||
Operand *parm = new Operand(in, tag);
|
||||
string = parm->string;
|
||||
doubleValue = parm->doubleValue;
|
||||
isNumber = parm->isNumber;
|
||||
delete parm;
|
||||
while(in.ifNext(",")) {
|
||||
parm = new Operand(in, tag);
|
||||
if(isNumber != parm->isNumber)
|
||||
throw coreutils::Exception("All parameters in MIN expression must be same type.");
|
||||
if(isNumber) {
|
||||
if(parm->doubleValue < doubleValue) {
|
||||
doubleValue = parm->doubleValue;
|
||||
string = parm->string;
|
||||
}
|
||||
} else {
|
||||
if(parm->string < string) {
|
||||
doubleValue = parm->doubleValue;
|
||||
string = parm->string;
|
||||
}
|
||||
}
|
||||
delete parm;
|
||||
}
|
||||
if(!in.ifNext(")")) {
|
||||
throw coreutils::Exception("Expecting ) at end of MIN expression.");
|
||||
}
|
||||
string.removeTrailingZeros();
|
||||
} else if(in.ifNextIgnoreCase("POW")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for POW parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in POW expression.");
|
||||
Operand parm2(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = pow(parm1.doubleValue, parm2.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of substring expression.");
|
||||
} else if(in.ifNextIgnoreCase("SIN")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for SIN parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = sin(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of SIN expression.");
|
||||
} else if(in.ifNextIgnoreCase("ASIN")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for ASIN parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = asin(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of ASIN expression.");
|
||||
} else if(in.ifNextIgnoreCase("COS")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for COS parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = cos(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of COS expression.");
|
||||
} else if(in.ifNextIgnoreCase("ACOS")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for ACOS parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = acos(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of ACOS expression.");
|
||||
} else if(in.ifNextIgnoreCase("ATAN")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for ATAN parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = atan(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of ATAN expression.");
|
||||
} else if(in.ifNextIgnoreCase("SQRT")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for SQRT parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = sqrt(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of SQRT expression.");
|
||||
} else if(in.ifNextIgnoreCase("DEG")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for DEG parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = parm1.doubleValue * 180 / 3.14159;
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of DEG expression.");
|
||||
} else if(in.ifNextIgnoreCase("RAD")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for RAD parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = parm1.doubleValue * 3.14159 / 180;
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of RAD expression.");
|
||||
} else if(in.ifNextIgnoreCase("TAN")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for TAN parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = tan(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of TAN expression.");
|
||||
} else if(in.ifNextIgnoreCase("TRUNC")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for TRUNC parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = trunc(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of TRUNC expression.");
|
||||
} else if(in.ifNextIgnoreCase("CEIL")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for CEIL parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = ceil(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of CEIL expression.");
|
||||
} else if(in.ifNextIgnoreCase("FLOOR")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for FLOOR parameters.");
|
||||
Operand parm1(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
doubleValue = floor(parm1.doubleValue);
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of FLOOR expression.");
|
||||
} else if(in.ifNextIgnoreCase("UNIXTIME") || in.ifNextIgnoreCase("UNIX_TIMESTAMP")) {
|
||||
// Real content (cart.page's own <set expr="unix_timestamp()">)
|
||||
// calls MySQL's real function name, not this codebase's own
|
||||
// "UNIXTIME" - same value, just accept both spellings.
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for UNIXTIME.");
|
||||
if(in.ifNext(")")) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto duration_since_epoch = now.time_since_epoch();
|
||||
auto seconds_since_epoch = std::chrono::duration_cast<std::chrono::seconds>(duration_since_epoch);
|
||||
int unixtime = seconds_since_epoch.count();
|
||||
string << unixtime;
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of UNIXTIME.");
|
||||
}
|
||||
else if(in.ifNextIgnoreCase("NOW")) {
|
||||
// MySQL's now() - real content (SESSIONCTL.tag's own
|
||||
// createsession definition: <set name="_timestamp" expr="now()">,
|
||||
// embedded directly into a DATETIME column via a raw SQL literal:
|
||||
// timestamp='$[_timestamp]') expects a MySQL DATETIME-formatted
|
||||
// string ("YYYY-MM-DD HH:MM:SS"), not a Unix timestamp (that's
|
||||
// UNIX_TIMESTAMP, just above).
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for NOW.");
|
||||
if(in.ifNext(")")) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm tmVal;
|
||||
gmtime_r(&t, &tmVal);
|
||||
char buf[32];
|
||||
std::strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tmVal);
|
||||
string = buf;
|
||||
isNumber = false;
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of NOW.");
|
||||
}
|
||||
else if(in.ifNextIgnoreCase("UUID")) {
|
||||
// MySQL's uuid() - real content (SESSIONCTL.tag's own
|
||||
// createsession definition: <set name="_uuid" expr="uuid()">)
|
||||
// uses this to mint a new session id, stored as sessions.uuid and
|
||||
// handed back to the browser as the _session_id cookie. A real
|
||||
// random (v4) UUID, not MySQL's actual v1 (time+MAC-derived)
|
||||
// algorithm - the schema only ever treats this as an opaque
|
||||
// unique string, nothing depends on v1's specific bit layout.
|
||||
// Seeded from std::random_device (real entropy), not RANDOM's
|
||||
// existing clock()-seeded rand_r() above - this value doubles as
|
||||
// a session token, so it needs to be unguessable, not just unique.
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for UUID.");
|
||||
if(in.ifNext(")")) {
|
||||
static thread_local std::mt19937_64 rng(std::random_device{}());
|
||||
std::uniform_int_distribution<int> hexDigit(0, 15);
|
||||
const char *hex = "0123456789abcdef";
|
||||
char buf[37];
|
||||
int p = 0;
|
||||
for(int i = 0; i < 36; i++) {
|
||||
if(i == 8 || i == 13 || i == 18 || i == 23) { buf[p++] = '-'; continue; }
|
||||
int v;
|
||||
if(i == 14) v = 4; // version 4
|
||||
else if(i == 19) v = 8 + hexDigit(rng) % 4; // variant 10xx
|
||||
else v = hexDigit(rng);
|
||||
buf[p++] = hex[v];
|
||||
}
|
||||
buf[p] = '\0';
|
||||
string = buf;
|
||||
isNumber = false;
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of UUID.");
|
||||
}
|
||||
else if(in.ifNextIgnoreCase("DATEDIFF")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for DATEDIFF.");
|
||||
Operand parm1(in, tag);
|
||||
if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in DATEDIFF expression.");
|
||||
Operand parm2(in, tag);
|
||||
if(in.ifNext(")")) {
|
||||
// Matches MySQL's DATEDIFF(expr1, expr2): expr1 - expr2 expressed
|
||||
// as a whole number of days, ignoring any time-of-day component.
|
||||
// Dates are parsed as YYYY-MM-DD (a leading date portion of a
|
||||
// longer "YYYY-MM-DD HH:MM:SS" value parses fine too, since
|
||||
// strptime only consumes what the format string asks for) and
|
||||
// interpreted as UTC via timegm() (not mktime(), which is
|
||||
// local-timezone-dependent) so the result doesn't shift with the
|
||||
// server's own timezone setting.
|
||||
struct tm tm1 = {};
|
||||
struct tm tm2 = {};
|
||||
if(!strptime(parm1.string.c_str(), "%Y-%m-%d", &tm1))
|
||||
throw coreutils::Exception("DATEDIFF: first argument is not a valid date (expected YYYY-MM-DD).");
|
||||
if(!strptime(parm2.string.c_str(), "%Y-%m-%d", &tm2))
|
||||
throw coreutils::Exception("DATEDIFF: second argument is not a valid date (expected YYYY-MM-DD).");
|
||||
time_t t1 = timegm(&tm1);
|
||||
time_t t2 = timegm(&tm2);
|
||||
doubleValue = difftime(t1, t2) / 86400.0;
|
||||
isNumber = true;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
} else
|
||||
throw coreutils::Exception("Expecting ) at end of DATEDIFF expression.");
|
||||
} else if(in.ifNextIgnoreCase("true")) {
|
||||
boolean = true;
|
||||
string = "true";
|
||||
@@ -132,14 +642,33 @@ namespace jet {
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
isNumber = true;
|
||||
} else if(in.ifNext("'")) {
|
||||
string = in.getTokenExclude("'");
|
||||
coreutils::MString raw = in.getTokenExclude("'");
|
||||
in.ifNext("'");
|
||||
coreutils::MString resolved;
|
||||
raw.reset();
|
||||
while(!raw.eod()) {
|
||||
if(raw.startsWith("$[") || raw.startsWith("#["))
|
||||
resolved.write(tag.getVariable(raw));
|
||||
else {
|
||||
resolved.write(raw.charAt(0));
|
||||
raw.nextChar();
|
||||
}
|
||||
}
|
||||
string = resolved;
|
||||
isNumber = false;
|
||||
} else
|
||||
throw coreutils::Exception("operand is not valid.");
|
||||
|
||||
in.skipWhitespace();
|
||||
|
||||
if(!stop)
|
||||
parseOperator();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int Operand::parseOperator() {
|
||||
|
||||
if(in.ifNext("!=") || in.ifNext("<>")) {
|
||||
Operand op(in, tag);
|
||||
if(isNumber && op.isNumber) {
|
||||
@@ -284,6 +813,8 @@ namespace jet {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(in.ifNext("+")) {
|
||||
if(isNumber) {
|
||||
Operand op(in, tag);
|
||||
@@ -308,28 +839,42 @@ namespace jet {
|
||||
throw coreutils::Exception("operand is not a number.");
|
||||
} else if(in.ifNext("*")) {
|
||||
if(isNumber) {
|
||||
Operand op(in, tag);
|
||||
Operand op(in, tag, true);
|
||||
if(op.isNumber) {
|
||||
doubleValue *= op.doubleValue;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
parseOperator();
|
||||
} else
|
||||
throw coreutils::Exception("operand is not a number.");
|
||||
} else
|
||||
throw coreutils::Exception("operand is not a number.");
|
||||
} else if(in.ifNext("/")) {
|
||||
if(isNumber) {
|
||||
Operand op(in, tag);
|
||||
Operand op(in, tag, true);
|
||||
if(op.isNumber) {
|
||||
doubleValue /= op.doubleValue;
|
||||
string = std::format("{:.12f}", doubleValue);
|
||||
string.removeTrailingZeros();
|
||||
parseOperator();
|
||||
} else
|
||||
throw coreutils::Exception("operand is not a number.");
|
||||
} else
|
||||
throw coreutils::Exception("operand is not a number.");
|
||||
} else
|
||||
return;
|
||||
}
|
||||
in.skipWhitespace();
|
||||
if(in.ifNextIgnoreCase("and")) {
|
||||
Operand op(in, tag);
|
||||
boolean = boolean && op.boolean;
|
||||
isNumber = false;
|
||||
string = boolean ? "true" : "false";
|
||||
} else if(in.ifNextIgnoreCase("or")) {
|
||||
Operand op(in, tag);
|
||||
boolean = boolean || op.boolean;
|
||||
isNumber = false;
|
||||
string = boolean ? "true" : "false";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,10 @@ namespace jet {
|
||||
class Operand {
|
||||
|
||||
public:
|
||||
Operand(coreutils::ZString &in, Tag &tag);
|
||||
Operand(coreutils::ZString &in, Tag &tag, bool stop = false);
|
||||
|
||||
coreutils::ZString ∈
|
||||
Tag &tag;
|
||||
|
||||
bool isNumber;
|
||||
|
||||
@@ -24,6 +27,8 @@ namespace jet {
|
||||
|
||||
double doubleValue;
|
||||
|
||||
int parseOperator();
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "SessionId.h"
|
||||
#include "Exception.h"
|
||||
#include <openssl/rand.h>
|
||||
|
||||
namespace jet {
|
||||
|
||||
// Previously SHA1("JETSESSION" + time(0)) - deterministic and
|
||||
// guessable from the wall-clock second alone (two sessions started in
|
||||
// the same second got the IDENTICAL id, and an attacker doesn't even
|
||||
// need a collision - the whole value is computable from a public,
|
||||
// narrow-range input). Confirmed via a real test: two separate
|
||||
// jet-2.0 runs with no cookie, back to back, produced the same
|
||||
// "fresh" session id. Replaced with 20 bytes straight from OpenSSL's
|
||||
// CSPRNG - RAND_bytes() is already available via libcrypto, which
|
||||
// every jet-2.0/jetc build already links against for other reasons.
|
||||
SessionId::SessionId() {
|
||||
unsigned char randomBytes[20];
|
||||
if(RAND_bytes(randomBytes, sizeof(randomBytes)) != 1)
|
||||
throw coreutils::Exception("failed to generate a random session id.");
|
||||
setSize(40);
|
||||
sprintf(getData(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||
randomBytes[0], randomBytes[1], randomBytes[2], randomBytes[3], randomBytes[4],
|
||||
randomBytes[5], randomBytes[6], randomBytes[7], randomBytes[8], randomBytes[9],
|
||||
randomBytes[10], randomBytes[11], randomBytes[12], randomBytes[13], randomBytes[14],
|
||||
randomBytes[15], randomBytes[16], randomBytes[17], randomBytes[18], randomBytes[19]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef __SessionId_h__
|
||||
#define __SessionId_h__
|
||||
|
||||
#include "MString.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
class SessionId : public coreutils::MString {
|
||||
|
||||
public:
|
||||
SessionId();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,305 @@
|
||||
#include "SqlBind.h"
|
||||
#include "Exception.h"
|
||||
#include <cctype>
|
||||
|
||||
namespace jet {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string lower(std::string s) {
|
||||
for(char &c : s) c = (char)std::tolower((unsigned char)c);
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string trim(const std::string &s) {
|
||||
size_t b = 0, e = s.size();
|
||||
while(b < e && std::isspace((unsigned char)s[b])) ++b;
|
||||
while(e > b && std::isspace((unsigned char)s[e - 1])) --e;
|
||||
return s.substr(b, e - b);
|
||||
}
|
||||
|
||||
std::string where(int position) {
|
||||
return "bind " + std::to_string(position) + ": ";
|
||||
}
|
||||
|
||||
bool allDigits(const std::string &s, size_t from, size_t to) {
|
||||
if(from >= to) return false;
|
||||
for(size_t i = from; i < to; ++i)
|
||||
if(!std::isdigit((unsigned char)s[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ^-?[0-9]{1,maxDigits}$
|
||||
bool isInteger(const std::string &s, size_t maxDigits) {
|
||||
size_t start = (!s.empty() && s[0] == '-') ? 1 : 0;
|
||||
size_t digits = s.size() - start;
|
||||
return digits >= 1 && digits <= maxDigits && allDigits(s, start, s.size());
|
||||
}
|
||||
|
||||
// ^-?[0-9]{1,30}(\.[0-9]{1,30})?$
|
||||
bool isDecimal(const std::string &s) {
|
||||
size_t dot = s.find('.');
|
||||
if(dot == std::string::npos) return isInteger(s, 30);
|
||||
std::string frac = s.substr(dot + 1);
|
||||
return isInteger(s.substr(0, dot), 30) && frac.size() >= 1 && frac.size() <= 30 && allDigits(frac, 0, frac.size());
|
||||
}
|
||||
|
||||
int num(const std::string &s, size_t at, size_t len) {
|
||||
return std::stoi(s.substr(at, len));
|
||||
}
|
||||
|
||||
// YYYY-MM-DD with a real month and day range.
|
||||
bool isDate(const std::string &s) {
|
||||
if(s.size() != 10 || s[4] != '-' || s[7] != '-') return false;
|
||||
if(!allDigits(s, 0, 4) || !allDigits(s, 5, 7) || !allDigits(s, 8, 10)) return false;
|
||||
int month = num(s, 5, 2), day = num(s, 8, 2);
|
||||
return month >= 1 && month <= 12 && day >= 1 && day <= 31;
|
||||
}
|
||||
|
||||
// YYYY-MM-DD HH:MM or YYYY-MM-DD HH:MM:SS
|
||||
bool isDateTime(const std::string &s) {
|
||||
if(s.size() != 16 && s.size() != 19) return false;
|
||||
if(!isDate(s.substr(0, 10)) || s[10] != ' ' || s[13] != ':') return false;
|
||||
if(!allDigits(s, 11, 13) || !allDigits(s, 14, 16)) return false;
|
||||
if(num(s, 11, 2) > 23 || num(s, 14, 2) > 59) return false;
|
||||
if(s.size() == 19) {
|
||||
if(s[16] != ':' || !allDigits(s, 17, 19) || num(s, 17, 2) > 59) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Walks query and calls onPlaceholder(index) for every '?' that is
|
||||
// outside '...', "...", `...`, -- / # line comments and /* */
|
||||
// comments. With NO_BACKSLASH_ESCAPES off, a backslash escapes the
|
||||
// next character inside '...' and "..."; with it on, it doesn't.
|
||||
// A doubled quote ('', "", ``) is an escaped quote in every mode.
|
||||
template<typename F>
|
||||
void scan(const std::string &q, bool noBackslashEscapes, F onPlaceholder) {
|
||||
size_t i = 0, n = q.size();
|
||||
while(i < n) {
|
||||
char c = q[i];
|
||||
if(c == '\'' || c == '"' || c == '`') {
|
||||
char quote = c;
|
||||
++i;
|
||||
while(i < n) {
|
||||
if(quote != '`' && !noBackslashEscapes && q[i] == '\\') { i += 2; continue; }
|
||||
if(q[i] == quote) {
|
||||
if(i + 1 < n && q[i + 1] == quote) { i += 2; continue; }
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(c == '#' || (c == '-' && i + 1 < n && q[i + 1] == '-' &&
|
||||
(i + 2 >= n || (unsigned char)q[i + 2] <= ' '))) {
|
||||
while(i < n && q[i] != '\n') ++i;
|
||||
continue;
|
||||
}
|
||||
if(c == '/' && i + 1 < n && q[i + 1] == '*') {
|
||||
size_t end = q.find("*/", i + 2);
|
||||
i = (end == std::string::npos) ? n : end + 2;
|
||||
continue;
|
||||
}
|
||||
if(c == '?') onPlaceholder(i);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// Lowercased words ([a-z0-9_@.$]) outside quotes and comments.
|
||||
std::vector<std::string> words(const std::string &q) {
|
||||
std::vector<std::string> out;
|
||||
std::string cur;
|
||||
size_t i = 0, n = q.size();
|
||||
auto flush = [&]() { if(!cur.empty()) { out.push_back(lower(cur)); cur.clear(); } };
|
||||
while(i < n) {
|
||||
char c = q[i];
|
||||
if(c == '\'' || c == '"' || c == '`') {
|
||||
flush();
|
||||
char quote = c;
|
||||
++i;
|
||||
while(i < n) {
|
||||
if(quote != '`' && q[i] == '\\') { i += 2; continue; }
|
||||
if(q[i] == quote) {
|
||||
if(i + 1 < n && q[i + 1] == quote) { i += 2; continue; }
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
out.push_back("'"); // a literal stands between words
|
||||
continue;
|
||||
}
|
||||
if(c == '#' || (c == '-' && i + 1 < n && q[i + 1] == '-' &&
|
||||
(i + 2 >= n || (unsigned char)q[i + 2] <= ' '))) {
|
||||
flush();
|
||||
while(i < n && q[i] != '\n') ++i;
|
||||
continue;
|
||||
}
|
||||
if(c == '/' && i + 1 < n && q[i + 1] == '*') {
|
||||
flush();
|
||||
size_t end = q.find("*/", i + 2);
|
||||
i = (end == std::string::npos) ? n : end + 2;
|
||||
continue;
|
||||
}
|
||||
if(std::isalnum((unsigned char)c) || c == '_' || c == '@' || c == '.' || c == '$')
|
||||
cur += c;
|
||||
else
|
||||
flush();
|
||||
++i;
|
||||
}
|
||||
flush();
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BoundValue makeBoundValue(const std::string &value,
|
||||
const std::string &typeIn,
|
||||
const std::string &nullModeIn,
|
||||
bool hasAllow,
|
||||
const std::string &allow,
|
||||
int position) {
|
||||
std::string type = typeIn.empty() ? "string" : lower(trim(typeIn));
|
||||
std::string nullMode = lower(trim(nullModeIn));
|
||||
|
||||
if(nullMode != "" && nullMode != "empty")
|
||||
throw coreutils::Exception(where(position) + "null must be \"empty\".");
|
||||
if(hasAllow && type != "ident")
|
||||
throw coreutils::Exception(where(position) + "allow is only valid with type=\"ident\".");
|
||||
|
||||
BoundValue b;
|
||||
if(nullMode == "empty" && value.empty()) {
|
||||
b.kind = BoundValue::SQLNULL;
|
||||
return b;
|
||||
}
|
||||
|
||||
if(type == "string") {
|
||||
b.kind = BoundValue::QUOTED;
|
||||
b.text = value;
|
||||
} else if(type == "int") {
|
||||
if(!isInteger(value, 19))
|
||||
throw coreutils::Exception(where(position) + "value is not a valid int.");
|
||||
b.kind = BoundValue::BARE;
|
||||
b.text = value;
|
||||
} else if(type == "decimal") {
|
||||
if(!isDecimal(value))
|
||||
throw coreutils::Exception(where(position) + "value is not a valid decimal.");
|
||||
b.kind = BoundValue::BARE;
|
||||
b.text = value;
|
||||
} else if(type == "bool") {
|
||||
std::string v = lower(value);
|
||||
b.kind = BoundValue::BARE;
|
||||
if(v == "1" || v == "true" || v == "yes")
|
||||
b.text = "1";
|
||||
else if(v == "0" || v == "false" || v == "no")
|
||||
b.text = "0";
|
||||
else
|
||||
throw coreutils::Exception(where(position) + "value is not a valid bool.");
|
||||
} else if(type == "date") {
|
||||
if(!isDate(value))
|
||||
throw coreutils::Exception(where(position) + "value is not a valid date (YYYY-MM-DD).");
|
||||
b.kind = BoundValue::QUOTED;
|
||||
b.text = value;
|
||||
} else if(type == "datetime") {
|
||||
if(!isDateTime(value))
|
||||
throw coreutils::Exception(where(position) + "value is not a valid datetime (YYYY-MM-DD HH:MM[:SS]).");
|
||||
b.kind = BoundValue::QUOTED;
|
||||
b.text = value;
|
||||
} else if(type == "ident") {
|
||||
if(!hasAllow)
|
||||
throw coreutils::Exception(where(position) + "type=\"ident\" requires an allow list.");
|
||||
// Match case-insensitively, but emit the allow list's own spelling:
|
||||
// what reaches the query always comes from the page, never the request.
|
||||
std::string match;
|
||||
bool found = false;
|
||||
size_t start = 0;
|
||||
while(start <= allow.size()) {
|
||||
size_t comma = allow.find(',', start);
|
||||
if(comma == std::string::npos) comma = allow.size();
|
||||
std::string entry = trim(allow.substr(start, comma - start));
|
||||
if(!entry.empty() && lower(entry) == lower(value)) {
|
||||
match = entry;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
start = comma + 1;
|
||||
}
|
||||
if(!found)
|
||||
throw coreutils::Exception(where(position) + "value is not in the allow list.");
|
||||
b.kind = BoundValue::BARE;
|
||||
std::string m = lower(match);
|
||||
if(m == "asc" || m == "desc") {
|
||||
b.text = (m == "asc") ? "ASC" : "DESC";
|
||||
} else {
|
||||
b.text = "`";
|
||||
for(char c : match) {
|
||||
if(c == '`') b.text += '`';
|
||||
b.text += c;
|
||||
}
|
||||
b.text += "`";
|
||||
}
|
||||
} else
|
||||
throw coreutils::Exception(where(position) + "unknown type \"" + type + "\".");
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
size_t countPlaceholders(const std::string &query, bool noBackslashEscapes) {
|
||||
size_t count = 0;
|
||||
scan(query, noBackslashEscapes, [&](size_t) { ++count; });
|
||||
return count;
|
||||
}
|
||||
|
||||
std::string bindPlaceholders(const std::string &query,
|
||||
const std::vector<BoundValue> &values,
|
||||
bool noBackslashEscapes,
|
||||
const std::function<std::string(const std::string &)> "eEscape) {
|
||||
std::vector<size_t> at;
|
||||
scan(query, noBackslashEscapes, [&](size_t i) { at.push_back(i); });
|
||||
if(at.size() != values.size())
|
||||
throw coreutils::Exception("sql: " + std::to_string(at.size()) + " placeholders but " +
|
||||
std::to_string(values.size()) + " bind values");
|
||||
std::string out;
|
||||
out.reserve(query.size() + 32 * values.size());
|
||||
size_t last = 0;
|
||||
for(size_t k = 0; k < at.size(); ++k) {
|
||||
out.append(query, last, at[k] - last);
|
||||
const BoundValue &v = values[k];
|
||||
if(v.kind == BoundValue::SQLNULL)
|
||||
out += "NULL";
|
||||
else if(v.kind == BoundValue::BARE)
|
||||
out += v.text;
|
||||
else {
|
||||
out += '\'';
|
||||
out += quoteEscape(v.text);
|
||||
out += '\'';
|
||||
}
|
||||
last = at[k] + 1;
|
||||
}
|
||||
out.append(query, last, std::string::npos);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool isCharsetChange(const std::string &query) {
|
||||
std::vector<std::string> w = words(query);
|
||||
if(w.empty() || w[0] != "set")
|
||||
return false;
|
||||
for(size_t i = 1; i < w.size(); ++i) {
|
||||
const std::string &x = w[i];
|
||||
if(x == "names" || x == "charset")
|
||||
return true;
|
||||
if(x == "character" && i + 1 < w.size() && w[i + 1] == "set")
|
||||
return true;
|
||||
// character_set_client, @@character_set_client, @@session.character_set_client, ...
|
||||
for(const char *var : {"character_set_client", "character_set_connection", "collation_connection"}) {
|
||||
std::string v(var);
|
||||
if(x.size() >= v.size() && x.compare(x.size() - v.size(), v.size(), v) == 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#ifndef __SqlBind_h__
|
||||
#define __SqlBind_h__
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Bound parameters for <sql> - see docs/design-sql-bound-parameters.md.
|
||||
//
|
||||
// Everything here is plain string logic with no MySQL or Tag dependency,
|
||||
// so it can be unit tested on its own (tests/sqlbind_test.cpp). __bind
|
||||
// builds BoundValues with makeBoundValue(); __sql substitutes them into
|
||||
// the rendered query with bindPlaceholders(), passing in the connection's
|
||||
// own escaping function.
|
||||
|
||||
namespace jet {
|
||||
|
||||
struct BoundValue {
|
||||
enum Kind {
|
||||
SQLNULL, // emitted as NULL
|
||||
BARE, // already validated (int/decimal/bool/ASC/DESC/`ident`) - emitted as is
|
||||
QUOTED // escaped with the connection's escaper and wrapped in '...'
|
||||
};
|
||||
Kind kind = QUOTED;
|
||||
std::string text;
|
||||
};
|
||||
|
||||
// Validates value against type and returns how it must be emitted.
|
||||
// position is the 1-based bind number, used only in error messages.
|
||||
// Error messages never contain the value itself (it may be a password).
|
||||
// type: string (default if empty), int, decimal, bool, date, datetime, ident
|
||||
// nullMode: "" (bind '' for an empty value) or "empty" (bind NULL)
|
||||
// allow: comma list of permitted identifiers - required for ident,
|
||||
// not allowed on any other type
|
||||
BoundValue makeBoundValue(const std::string &value,
|
||||
const std::string &type,
|
||||
const std::string &nullMode,
|
||||
bool hasAllow,
|
||||
const std::string &allow,
|
||||
int position);
|
||||
|
||||
// Number of '?' placeholders in query that are outside string literals,
|
||||
// backtick identifiers and comments.
|
||||
size_t countPlaceholders(const std::string &query, bool noBackslashEscapes);
|
||||
|
||||
// Replaces each placeholder (as counted above) with the matching bound
|
||||
// value, in order. Throws if the placeholder and value counts differ.
|
||||
// quoteEscape escapes the body of a single-quoted string literal (no
|
||||
// surrounding quotes) for the actual connection.
|
||||
std::string bindPlaceholders(const std::string &query,
|
||||
const std::vector<BoundValue> &values,
|
||||
bool noBackslashEscapes,
|
||||
const std::function<std::string(const std::string &)> "eEscape);
|
||||
|
||||
// True for a SET statement that changes the connection character set
|
||||
// (SET NAMES, SET CHARACTER SET, SET CHARSET, or an assignment to
|
||||
// character_set_client / character_set_connection / collation_connection).
|
||||
// Changing it after connect makes client-side escaping and server-side
|
||||
// parsing disagree, so <sql> refuses these.
|
||||
bool isCharsetChange(const std::string &query);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -9,8 +9,4 @@ file name and content length from variable. $[data(filename)] and
|
||||
$[data(length)] possibly.
|
||||
4)
|
||||
|
||||
BUG LIST
|
||||
|
||||
1) Call tag is acting wierd. Look at testcall.jet.
|
||||
2) Fix the variable retriever to perform all variable translation
|
||||
before fetching value processing.
|
||||
@@ -6,15 +6,23 @@
|
||||
#include "Global.h"
|
||||
#include <map>
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
class Tag : public coreutils::ZString {
|
||||
|
||||
public:
|
||||
Tag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent = NULL, Tag *local = NULL, coreutils::ZString splitTagName = "");
|
||||
Tag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent = NULL, Tag *local = NULL, coreutils::ZString splitTagName = ""); //!>Constructor
|
||||
virtual ~Tag();
|
||||
|
||||
coreutils::MString getVariable(coreutils::ZString &variable, bool inContainer = false);
|
||||
coreutils::MString getVariable(coreutils::ZString &variable, bool inContainer = false); //!>retrieve a vairable value from a text string cotontaining a variable name.
|
||||
|
||||
coreutils::MString resolveKeyword(coreutils::ZString keyword);
|
||||
std::map<coreutils::MString, coreutils::MString> variables;
|
||||
@@ -26,12 +34,64 @@ namespace jet {
|
||||
Tag *parent;
|
||||
Tag *local;
|
||||
|
||||
// Public write counterpart to the public getVariable() read path -
|
||||
// needed by anything (e.g. compiled/codegen'd output) that assigns
|
||||
// variables without being a Tag subclass itself. See Tag.cpp for the
|
||||
// "@name" session-file routing this also handles.
|
||||
void assignVariable(coreutils::ZString variable, coreutils::MString value, coreutils::ZString scope);
|
||||
|
||||
// Falls back to the normal text-scanning interpreter (parseContainer)
|
||||
// for a raw source span - used by generated code to run any tag a
|
||||
// compiler doesn't have a codegen rule for yet, without duplicating
|
||||
// the 22 tag classes' logic.
|
||||
void interpretSpan(coreutils::ZString span, coreutils::MString &out);
|
||||
|
||||
// Custom <tag name="..."> scoping: a Tag defined directly inside
|
||||
// another custom tag's own invocation (i.e. inside a __dotag
|
||||
// instance's expansion, not just nested inside <if>/<for>/etc. that
|
||||
// happen to sit there) registers into that invocation's own
|
||||
// localTags instead of the single flat global.tags map, so it's
|
||||
// only visible for the rest of that invocation - not the whole
|
||||
// script. isCustomTagBoundary is true only on __dotag instances
|
||||
// (set in __dotag's own constructor body); every other tag leaves
|
||||
// it false and is transparently walked past when searching for an
|
||||
// enclosing scope, exactly like <if>/<for>/<while> already are for
|
||||
// parent-chain purposes elsewhere. Public (like variables/keywords/
|
||||
// name/etc. above) rather than protected - __tag.cpp needs to read
|
||||
// and write these through an arbitrary ancestor Tag* found by
|
||||
// walking parent, not just on its own `this`, and protected access
|
||||
// in C++ only extends to a derived class's own (sub)object, not to
|
||||
// another object reached through a base-class-typed pointer.
|
||||
bool isCustomTagBoundary = false;
|
||||
std::map<coreutils::MString, coreutils::MString> localTags;
|
||||
|
||||
// Walks from `this` up through `parent` looking for the nearest
|
||||
// isCustomTagBoundary ancestor whose localTags has `name`, falling
|
||||
// back to global.tags - used by both ifTagDefined() (is <name>
|
||||
// visible right here?) and __dotag's own constructor (fetch the
|
||||
// actual definition to expand).
|
||||
bool findTagDefinition(coreutils::MString name, coreutils::ZString &result);
|
||||
|
||||
// Renders the enclosing custom tag invocation's own nested content -
|
||||
// the <container> marker inside a <tag name="X"> definition body -
|
||||
// into `out`. Extracted, unchanged, from parseContainer's own
|
||||
// "container" dispatch branch (see Tag.cpp) so generated code for a
|
||||
// compiled tag-definition body (see jetc's TAGDEF handling) can call
|
||||
// this exact logic directly instead of going through the raw-text
|
||||
// scan to reach it - walks up from `local` to the nearest
|
||||
// isCustomTagBoundary ancestor not already being resolved (guards
|
||||
// the pass-through self-reference case, e.g. linkbutton's own
|
||||
// <EVAL><CONTAINER></EVAL>) and renders THAT scope's own ->container;
|
||||
// falls back to rendering container2 if no such ancestor exists,
|
||||
// exactly matching parseContainer's own fallback for the same case.
|
||||
void renderContainer(coreutils::MString &out, coreutils::ZString container2 = NULL);
|
||||
|
||||
protected:
|
||||
bool hasContainer = false;
|
||||
bool hasContainer2 = false;
|
||||
bool keywordDefined(coreutils::ZString variable);
|
||||
void parseContainer(coreutils::ZString &in, coreutils::MString &out, coreutils::ZString container2 = NULL);
|
||||
void processContainer(coreutils::ZString &container, coreutils::ZString container2 = NULL);
|
||||
void parseContainer(coreutils::ZString &in, coreutils::MString &out, coreutils::ZString container2 = NULL, bool topLevel = false);
|
||||
void processContainer(coreutils::ZString &container, coreutils::ZString container2 = NULL, bool topLevel = false);
|
||||
void copyContainer(coreutils::ZString &in, coreutils::MString &out);
|
||||
|
||||
coreutils::MString &parentOut;
|
||||
@@ -61,7 +121,30 @@ namespace jet {
|
||||
bool ifEndTagName(coreutils::ZString &in);
|
||||
bool ifSplitTagName(coreutils::ZString &in);
|
||||
|
||||
// ifNested(in)'s own same-name-only check misses a DIFFERENTLY
|
||||
// named nested split-tag construct - e.g. an <if> nested inside an
|
||||
// <ifrow>'s own body (both use splitTagName "else"): ifNested(in)
|
||||
// only recognizes another nested <ifrow>, so an inner <if>'s own
|
||||
// <else>/</if> markers were being read as if they belonged to the
|
||||
// OUTER <ifrow>'s own boundary scan, corrupting both. This overload
|
||||
// set (ifNested/ifEndTagName parameterized by an explicit tag name,
|
||||
// plus scanContainerNamed) generalizes the exact same logic to any
|
||||
// of the built-in splitTagName="else" conditionals - if/while/
|
||||
// until/ifrow - so the outer tag's boundary scan correctly skips
|
||||
// PAST an inner one of any of these, regardless of name, before
|
||||
// resuming its own search. See Tag.cpp's own doc comment on the
|
||||
// shared splitTagNames list for the real story/repro.
|
||||
bool ifNested(coreutils::ZString &in, const char *tagName);
|
||||
bool ifEndTagName(coreutils::ZString &in, const char *tagName);
|
||||
void scanContainerNamed(coreutils::ZString &in, const char *tagName);
|
||||
|
||||
coreutils::MString processModifier(coreutils::MString &value, coreutils::MString &modifier);
|
||||
|
||||
public:
|
||||
// The split tag's own attributes (raw, unresolved) - e.g. <try>'s
|
||||
// <catch name="err">, so __trytag can bind the error to that name.
|
||||
// Last member on purpose: adding it changes no other member's offset.
|
||||
std::map<coreutils::MString, coreutils::MString> splitKeywords;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "__bind.h"
|
||||
#include "__sql.h"
|
||||
#include "Exception.h"
|
||||
#include "SqlBind.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
__bind::__bind(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
output = false;
|
||||
|
||||
// Nearest enclosing <sql>, through any <if>/<for>/etc. in between.
|
||||
__sql *sql = NULL;
|
||||
for(Tag *scope = parent; scope && !sql; scope = scope->parent)
|
||||
sql = dynamic_cast<__sql *>(scope);
|
||||
if(!sql)
|
||||
throw coreutils::Exception("bind must be inside sql.");
|
||||
if(!keywordDefined("value"))
|
||||
throw coreutils::Exception("bind must have a value.");
|
||||
|
||||
std::string value = resolveKeyword("value").str();
|
||||
std::string type = keywordDefined("type") ? resolveKeyword("type").str() : "";
|
||||
std::string nullMode = keywordDefined("null") ? resolveKeyword("null").str() : "";
|
||||
bool hasAllow = keywordDefined("allow");
|
||||
std::string allow = hasAllow ? resolveKeyword("allow").str() : "";
|
||||
|
||||
sql->addBind(makeBoundValue(value, type, nullMode, hasAllow, allow, (int)sql->bindCount() + 1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef ____bind_h__
|
||||
#define ____bind_h__
|
||||
|
||||
#include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
// <bind value="..." [type="..."] [null="empty"] [allow="a,b"]> - supplies
|
||||
// the value for the next '?' placeholder of the enclosing <sql>. Always
|
||||
// void (no closing tag) and produces no output. See
|
||||
// docs/design-sql-bound-parameters.md.
|
||||
class __bind : public Tag {
|
||||
|
||||
public:
|
||||
__bind(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
#include "__call.h"
|
||||
#include "Exception.h"
|
||||
#include "MString.h"
|
||||
@@ -6,45 +7,99 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__call::__call(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
if(hasContainer)
|
||||
throw coreutils::Exception("call tag cannot have a container.");
|
||||
if(hasContainer && keywordDefined("input"))
|
||||
throw coreutils::Exception("call tag cannot have both input keyword and have a container.");
|
||||
if(!keywordDefined("pgm"))
|
||||
throw coreutils::Exception("pgm keyword must be specified.");
|
||||
for(ix = 0; ix <= 50; ++ix)
|
||||
for(ix = 0; ix < 50; ++ix)
|
||||
argv[ix] = NULL;
|
||||
argv[0] = resolveKeyword("pgm").c_str(); // TODO: Need to peel off the program name only and pass as argv[0].
|
||||
for(ix = 1; ix <= 50; ++ix) {
|
||||
// Reserve up front - argStrings must never reallocate once a
|
||||
// c_str() pointer from one of its elements has been stored into
|
||||
// argv[] below, or that pointer dangles exactly like the bug this
|
||||
// replaces (see the .h's own comment). 50 arg slots + argv[0]'s
|
||||
// own program name.
|
||||
argStrings.reserve(51);
|
||||
argStrings.push_back(resolveKeyword("pgm")); // TODO: Need to peel off the program name only and pass as argv[0].
|
||||
argv[0] = argStrings.back().c_str();
|
||||
for(ix = 1; ix < 50; ++ix) {
|
||||
coreutils::MString arg("arg");
|
||||
arg << ix;
|
||||
if(keywordDefined(arg)) {
|
||||
argv[ix] = resolveKeyword(arg).c_str();
|
||||
argStrings.push_back(resolveKeyword(arg));
|
||||
argv[ix] = argStrings.back().c_str();
|
||||
} else
|
||||
break;
|
||||
}
|
||||
pipe(fdo);
|
||||
// pipe()/fork() both used to go unchecked here - on failure (most
|
||||
// realistically pipe() hitting the process's open-file-descriptor
|
||||
// limit, see below) fdo[] is left holding whatever garbage was
|
||||
// already on the stack/in this member array, and every use of it
|
||||
// after this point (close(), read(), and - for a failed fork() -
|
||||
// waitpid(-1, ...), which has the special POSIX meaning "wait for
|
||||
// ANY child" rather than "wait for none") operates on that garbage
|
||||
// or on an unrelated process instead of safely no-oping. That's a
|
||||
// real, confirmed mechanism for exactly the kind of sporadic
|
||||
// memory corruption this codebase has seen: closing/reading a
|
||||
// stale fd that coincidentally matches another subsystem's live
|
||||
// socket, or reaping a concurrent request's own child out from
|
||||
// under it.
|
||||
if(pipe(fdo) != 0)
|
||||
throw coreutils::Exception("call: pipe() failed - " + std::string(strerror(errno)), __FILE__, __LINE__, 500);
|
||||
pid = fork();
|
||||
if(pid < 0) {
|
||||
close(fdo[0]);
|
||||
close(fdo[1]);
|
||||
throw coreutils::Exception("call: fork() failed - " + std::string(strerror(errno)), __FILE__, __LINE__, 500);
|
||||
}
|
||||
if(pid == 0) {
|
||||
close(fdo[0]);
|
||||
dup2(fdo[1], 1);
|
||||
if(keywordDefined("input")) {
|
||||
coreutils::MString input(resolveKeyword("input"));
|
||||
pipe(fdi);
|
||||
if(fork() == 0) {
|
||||
close(fdi[0]);
|
||||
write(fdi[1], input.getData(), input.getLength());
|
||||
close(fdi[1]);
|
||||
exit(0);
|
||||
if(hasContainer) {
|
||||
if(pipe(fdi) == 0) {
|
||||
pid_t innerPid = fork();
|
||||
if(innerPid == 0) {
|
||||
close(fdi[0]);
|
||||
write(fdi[1], container.getData(), container.getLength());
|
||||
close(fdi[1]);
|
||||
_exit(0);
|
||||
} else if(innerPid > 0) {
|
||||
close(fdi[1]);
|
||||
dup2(fdi[0], 0);
|
||||
close(fdi[0]);
|
||||
} else {
|
||||
close(fdi[0]);
|
||||
close(fdi[1]);
|
||||
}
|
||||
}
|
||||
} else if(keywordDefined("input")) {
|
||||
coreutils::MString input(resolveKeyword("input"));
|
||||
if(pipe(fdi) == 0) {
|
||||
pid_t innerPid = fork();
|
||||
if(innerPid == 0) {
|
||||
close(fdi[0]);
|
||||
write(fdi[1], input.getData(), input.getLength());
|
||||
close(fdi[1]);
|
||||
_exit(0);
|
||||
} else if(innerPid > 0) {
|
||||
close(fdi[1]);
|
||||
dup2(fdi[0], 0);
|
||||
close(fdi[0]);
|
||||
} else {
|
||||
close(fdi[0]);
|
||||
close(fdi[1]);
|
||||
}
|
||||
}
|
||||
close(fdi[1]);
|
||||
dup2(fdi[0], 0);
|
||||
}
|
||||
rc = execvpe(resolveKeyword("pgm").c_str(), argv, global.envp);
|
||||
rc = execvpe(argv[0], argv, global.envp);
|
||||
close(fdo[1]);
|
||||
exit(errno);
|
||||
_exit(errno);
|
||||
}
|
||||
close(fdo[1]);
|
||||
if(keywordDefined("name")) {
|
||||
@@ -53,6 +108,18 @@ namespace jet {
|
||||
storeVariable(resolveKeyword("name"), value, resolveKeyword("scope"));
|
||||
} else
|
||||
out.read(fdo[0]);
|
||||
// fdo[0] (the read end, still open in this - the parent - process)
|
||||
// was never closed here before, leaking one file descriptor on
|
||||
// every single <call> invocation for the life of the process.
|
||||
// Harmless-looking for an occasional <call>, but <call> is used
|
||||
// throughout this codebase (jq/curl parsing, mailcreate, this
|
||||
// session's own per-line-item JS-escaping on the invoice editor,
|
||||
// which alone can issue a double-digit number of calls per page
|
||||
// load) - repeated, routine use was slowly accumulating leaked
|
||||
// fds for as long as this process stayed up, eventually hitting
|
||||
// the real open-files limit and turning into exactly the pipe()
|
||||
// failures (and the undefined behavior above) this fix addresses.
|
||||
close(fdo[0]);
|
||||
waitpid(pid, &status, 0);
|
||||
if(keywordDefined("error")) {
|
||||
global.variables[resolveKeyword("error")] = (status >> 8 & 255);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define ____call_h__
|
||||
|
||||
#include "Tag.h"
|
||||
#include <vector>
|
||||
|
||||
namespace jet {
|
||||
|
||||
@@ -19,6 +20,21 @@ namespace jet {
|
||||
int rc;
|
||||
char *argv[50];
|
||||
|
||||
// Owns the actual character storage argv[] points into. Resolved
|
||||
// MStrings used to be created as unnamed temporaries with only
|
||||
// their .c_str() pointer kept (argv[ix] = resolveKeyword(arg)
|
||||
// .c_str()) - the temporary is destroyed at the end of that same
|
||||
// statement, so argv[ix] was a dangling pointer from that point
|
||||
// on, read only much later by execvpe() in the forked child.
|
||||
// Undefined behavior - confirmed via a real repro: two sequential
|
||||
// <call> tags (date, then cp using date's own captured output)
|
||||
// corrupted each other's arguments, producing a "cp" invocation
|
||||
// that actually ran /bin/date with garbage arguments instead.
|
||||
// Reserved to its final size up front (see the constructor) so no
|
||||
// push_back can reallocate and invalidate a c_str() pointer
|
||||
// already stored in argv[] earlier in the same construction.
|
||||
std::vector<coreutils::MString> argStrings;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,64 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__dotag::__dotag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
coreutils::ZString container3 = global.tags[name];
|
||||
processContainer(container3, container);
|
||||
__dotag::__dotag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
|
||||
// Every invocation of a custom tag is itself a new scope boundary -
|
||||
// a <tag name="..."> encountered while expanding this invocation's
|
||||
// own template (below) registers into THIS instance's localTags,
|
||||
// not the global map, so it's only visible for the rest of this
|
||||
// expansion. See Tag.h's isCustomTagBoundary/localTags doc comment.
|
||||
//
|
||||
// local=this (bound above, in the base Tag constructor call rather
|
||||
// than forwarding the caller's own local) is what makes a custom
|
||||
// tag's own body see ITS OWN declared/passed attributes via
|
||||
// #[name] - matches the pattern __if/__while/__until already use
|
||||
// for the same reason. Without this, #[name] reads inside e.g.
|
||||
// SESSIONCTL.tag's <sessionctl>/<setpage>/<retain> bodies resolved
|
||||
// against whatever local scope happened to be active in the
|
||||
// caller instead of this invocation's own attributes, and always
|
||||
// fell through to the empty-string fallback.
|
||||
isCustomTagBoundary = true;
|
||||
|
||||
// The base Tag constructor already set hasContainer from whether
|
||||
// THIS INVOCATION was self-closing (<name /> vs <name>...</name>) -
|
||||
// that's the right question for capturing this invocation's own
|
||||
// nested content into `container` above, but the wrong one for
|
||||
// whether the tag's DEFINITION (container3 below) should render:
|
||||
// a self-closing invocation of a tag whose definition doesn't use
|
||||
// <container /> at all is completely normal and should still
|
||||
// render. Found this as a real, pre-existing bug while testing
|
||||
// this scoping feature - <name /> always silently rendered nothing
|
||||
// for ANY custom tag, only <name></name> worked, since
|
||||
// processContainer() gates on hasContainer. Force it true here:
|
||||
// by this point a valid definition is guaranteed to exist (dispatch
|
||||
// only constructs __dotag after ifTagDefined() already confirmed
|
||||
// it), so there's always something to render regardless of how
|
||||
// this invocation was written.
|
||||
hasContainer = true;
|
||||
|
||||
// Fast path: if jetc compiled this tag's definition directly (a
|
||||
// top-level <tag name="X"> - see JetCodegen's TAGDEF handling), a
|
||||
// render function was registered under its lowercase name (matching
|
||||
// __tag.cpp's own registration key convention) instead of - or
|
||||
// alongside - the raw text findTagDefinition()/processContainer()
|
||||
// below would otherwise have to re-parse on every single invocation.
|
||||
// A miss here (locally-scoped/nested definitions, or a tag that was
|
||||
// never part of a compiled module) falls straight through to that
|
||||
// exact same interpreted path, unchanged - see Global.h's own doc
|
||||
// comment on compiledTags.
|
||||
coreutils::MString nameLower = coreutils::MString(name).toLower();
|
||||
auto compiledIt = global.compiledTags.find(nameLower);
|
||||
if(compiledIt != global.compiledTags.end()) {
|
||||
// Same gate processContainer() below applies on the interpreted
|
||||
// path - keeps both paths behaviorally identical rather than
|
||||
// having the compiled fast path unconditionally render.
|
||||
if(hasContainer && evaluate)
|
||||
compiledIt->second(*this, out);
|
||||
} else {
|
||||
coreutils::ZString container3;
|
||||
if(!findTagDefinition(name, container3))
|
||||
throw coreutils::Exception("tag definition not found.");
|
||||
processContainer(container3, container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Exception.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
namespace jet {
|
||||
|
||||
@@ -13,8 +14,8 @@ namespace jet {
|
||||
|
||||
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;
|
||||
// for (auto i = global.cgiVariables.begin(); i != global.cgiVariables.end(); i++)
|
||||
// outFile << i->first << "=[" << i->second << "]" << std::endl;
|
||||
}
|
||||
|
||||
outFile << "*** GLOBAL VARIABLES ***" << std::endl;
|
||||
@@ -33,6 +34,37 @@ namespace jet {
|
||||
for (auto i = global.cookies.data.begin(); i != global.cookies.data.end(); i++)
|
||||
outFile << i->first << "=[" << i->second << "]" << std::endl;
|
||||
|
||||
// Custom <tag name="..."> definitions now have real scoping - one
|
||||
// defined directly inside another custom tag's own invocation is
|
||||
// only visible for the rest of that invocation (see Tag.h's
|
||||
// isCustomTagBoundary/localTags doc comment). Render the actual
|
||||
// tree currently in effect at this point in the script: global at
|
||||
// the root, then each enclosing custom-tag invocation nested one
|
||||
// level deeper, outermost first - if there's no active local scope
|
||||
// (this <dump> isn't running inside any custom tag's expansion),
|
||||
// that's just the root with nothing nested under it.
|
||||
outFile << "*** DEFINED TAGS ***" << std::endl;
|
||||
outFile << "(global)" << std::endl;
|
||||
for (auto i = global.tags.begin(); i != global.tags.end(); i++)
|
||||
outFile << " " << i->first << std::endl;
|
||||
|
||||
std::vector<Tag *> scopeChain;
|
||||
for (Tag *scope = this; scope; scope = scope->parent)
|
||||
if (scope->isCustomTagBoundary)
|
||||
scopeChain.push_back(scope);
|
||||
|
||||
int depth = 1;
|
||||
for (auto it = scopeChain.rbegin(); it != scopeChain.rend(); ++it) {
|
||||
Tag *boundary = *it;
|
||||
coreutils::MString indent;
|
||||
for (int d = 0; d < depth; d++)
|
||||
indent << " ";
|
||||
outFile << indent << "(inside " << boundary->name << ")" << std::endl;
|
||||
for (auto i = boundary->localTags.begin(); i != boundary->localTags.end(); i++)
|
||||
outFile << indent << " " << i->first << std::endl;
|
||||
depth++;
|
||||
}
|
||||
|
||||
outFile.close();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "__eval.h"
|
||||
#include "Exception.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
// <eval> is not a jet-2.0 addition - it's a genuine jet-1.4 tag that was
|
||||
// simply never implemented in 2.0 at all (no class, no dispatch entry
|
||||
// anywhere). SESSIONCTL.tag's own <page> definition depends on it
|
||||
// throughout - capturing a tag's own invocation content into a named
|
||||
// variable (<eval name="_BODY"><container></eval>, often with
|
||||
// scope="parent" so a nested custom tag can write back into its
|
||||
// caller's scope: <eval name="AUTHOR" scope="parent">...), and also
|
||||
// using it bare (no name=) to render an <include>'d file's content
|
||||
// inline (<eval><include file="...page"></eval>). Without this tag,
|
||||
// all of that content was silently falling through as undefined-tag
|
||||
// literal text, which is why a real, unmodified SESSIONCTL.tag <page>
|
||||
// never produced its actual rendered body.
|
||||
//
|
||||
// <eval name="X" [scope="local|parent|global"]>content</eval> - same
|
||||
// capture semantics as <set name="X">content</set> (Tag::storeVariable
|
||||
// already implements exactly this: interpret the container, then store
|
||||
// the result - raw if the container itself specified eval="no", already
|
||||
// evaluated otherwise - into variable X at the requested scope,
|
||||
// defaulting to global like <set> does). Reused directly rather than
|
||||
// reimplemented, since it's the identical contract under a different
|
||||
// tag name.
|
||||
//
|
||||
// <eval>content</eval> (no name=) - content is interpreted and flows to
|
||||
// normal output, exactly like any ordinary container-having tag; no
|
||||
// special-casing needed since output/evaluate already default to true
|
||||
// on the base Tag class and the destructor's copyContainer(out,
|
||||
// parentOut) handles the rest once processContainer(container) below
|
||||
// has populated `out`.
|
||||
__eval::__eval(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
if(keywordDefined("name")) {
|
||||
storeVariable(resolveKeyword("name"));
|
||||
output = false;
|
||||
} else if(hasContainer) {
|
||||
processContainer(container);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef ____eval_h__
|
||||
#define ____eval_h__
|
||||
|
||||
#include "Tag.h"
|
||||
#include "ZString.h"
|
||||
#include "MString.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
class __eval : public Tag {
|
||||
|
||||
public:
|
||||
__eval(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "__exclude.h"
|
||||
#include "Exception.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
__exclude::__exclude(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
|
||||
if(!hasContainer)
|
||||
throw coreutils::Exception("exclude must have a container.");
|
||||
output = true;
|
||||
evaluate = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef ____exclude_h__
|
||||
#define ____exclude_h__
|
||||
|
||||
#include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
class __exclude : public Tag {
|
||||
|
||||
public:
|
||||
__exclude(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -15,18 +15,40 @@ namespace jet {
|
||||
throw coreutils::Exception("for tag requires end keyword.");
|
||||
if(!keywordDefined("step"))
|
||||
throw coreutils::Exception("for tag requires step keyword.");
|
||||
|
||||
// Where to write the loop counter (which variables map, and under
|
||||
// what name) is a static property of this <for>'s own invocation -
|
||||
// "scope"/"name" have no sensible reason to change mid-loop, so
|
||||
// resolve and branch on them once instead of re-resolving both
|
||||
// (and re-checking scope with up to 3 comparisons) on every single
|
||||
// iteration. Loop bounds (end/step) are deliberately left
|
||||
// re-resolved per iteration exactly as before - real content could
|
||||
// plausibly rely on a bound that changes as a side effect of the
|
||||
// loop body itself, and there's no clear evidence either way, so
|
||||
// that part stays conservative/unchanged.
|
||||
coreutils::MString counterVarName;
|
||||
enum { SCOPE_GLOBAL, SCOPE_LOCAL, SCOPE_PARENT } counterScope = SCOPE_GLOBAL;
|
||||
if(nameDefined) {
|
||||
counterVarName = resolveKeyword("name");
|
||||
if(keywordDefined("scope")) {
|
||||
coreutils::MString scopeVal = resolveKeyword("scope");
|
||||
if(scopeVal == "global") counterScope = SCOPE_GLOBAL;
|
||||
else if(scopeVal == "local") counterScope = SCOPE_LOCAL;
|
||||
else if(scopeVal == "parent") counterScope = SCOPE_PARENT;
|
||||
else throw coreutils::Exception("scope value is not valid.");
|
||||
}
|
||||
}
|
||||
|
||||
for(double ix = counter; ix <= resolveKeyword("end").asDouble(); ix += resolveKeyword("step").asDouble()) {
|
||||
resolveKeyword("end").reset();
|
||||
resolveKeyword("step").reset();
|
||||
if(nameDefined) {
|
||||
if(!keywordDefined("scope") || (resolveKeyword("scope") == "global"))
|
||||
global.variables[resolveKeyword("name")] = ix;
|
||||
else if(resolveKeyword("scope") == "local")
|
||||
this->local->variables[resolveKeyword("name")] = ix;
|
||||
else if(resolveKeyword("scope") == "parent")
|
||||
parent->local->variables[resolveKeyword("name")] = ix;
|
||||
if(counterScope == SCOPE_GLOBAL)
|
||||
global.variables[counterVarName] = ix;
|
||||
else if(counterScope == SCOPE_LOCAL)
|
||||
this->local->variables[counterVarName] = ix;
|
||||
else
|
||||
throw coreutils::Exception("scope value is not valid.");
|
||||
parent->local->variables[counterVarName] = ix;
|
||||
}
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace jet {
|
||||
throw coreutils::Exception("type expected if value1 and value2 specified.");
|
||||
} else
|
||||
throw coreutils::Exception("value2 required if value1 specified.");
|
||||
coreutils::MString type = resolveKeyword("type");
|
||||
coreutils::MString type = resolveKeyword("type").toLower();
|
||||
if((type != "eq") &&
|
||||
(type != "ne") &&
|
||||
(type != "lt") &&
|
||||
|
||||
@@ -8,12 +8,32 @@
|
||||
namespace jet {
|
||||
|
||||
__ifrow::__ifrow(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this, "else") {
|
||||
output = false;
|
||||
// NOT setting output=false here (an earlier version of this file
|
||||
// did) - that flag gates Tag::~Tag()'s own copyContainer(out,
|
||||
// parentOut) call, the mechanism that propagates whatever
|
||||
// processContainer() below actually wrote up to this tag's own
|
||||
// caller. <ifrow>'s entire purpose is to conditionally DISPLAY one
|
||||
// of its two branches (exactly like <if>/<while>/<until>, none of
|
||||
// which ever touch `output`) - unlike the tags that legitimately
|
||||
// do set it (<set>/<sql>/<cookie>/<header>/<write>/<tag>/
|
||||
// <comment>/<stream>, none of which have any visible content of
|
||||
// their own to emit), so setting it here silently discarded
|
||||
// EVERY <ifrow>'s rendered content, true branch or false, on every
|
||||
// single use. Confirmed live via gdb-style tracing: hasRow(),
|
||||
// the resolved session pointer, and container's own text were all
|
||||
// exactly correct at the point processContainer(container) ran -
|
||||
// the content just never reached parentOut because the destructor
|
||||
// skipped the copy. Never caught before because no real content
|
||||
// this session exercised an <ifrow> with real row data AND had
|
||||
// its rendered output actually inspected (account.page's own
|
||||
// <ifrow sessionid="projman"> usage always redirected before
|
||||
// reaching it, for lack of a login session).
|
||||
if(!hasContainer)
|
||||
throw coreutils::Exception("ifrow tag must have a container.");
|
||||
if(!global.sessionExists(keywords[resolveKeyword("sessionid")]))
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if(!global.sessionExists(sessionId))
|
||||
throw coreutils::Exception("sessionid does not exist.");
|
||||
if(global.getSession(keywords[resolveKeyword("sessionid")])->hasRow())
|
||||
if(global.getSession(sessionId)->hasRow())
|
||||
processContainer(container);
|
||||
else
|
||||
processContainer(container2);
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
#ifndef ____imap_h__
|
||||
# define ____imap_h__
|
||||
|
||||
# include "Tag.h"
|
||||
# include "ZString.h"
|
||||
# include "MString.h"
|
||||
# include <cstdint>
|
||||
# include <openssl/ssl.h>
|
||||
# include <string>
|
||||
# include <vector>
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imap config="./email.cfg" user="..." password="..." sessionid="">
|
||||
///
|
||||
/// Connects to the IMAP host named in the JSON file `config` (keys:
|
||||
/// host, port, caCertificate - see email.cfg), TLS-handshakes
|
||||
/// (implicit TLS, matching IMAP's standard port 993 - no STARTTLS
|
||||
/// negotiation), and LOGINs with user/password. Throws
|
||||
/// coreutils::Exception (with errorNumber set to a real HTTP status -
|
||||
/// 401 for a bad login, 502 for a connection/protocol failure) on any
|
||||
/// failure, exactly like __mysql throws on a failed
|
||||
/// mysql_real_connect() - see ApiSession.cpp's exception->HTTP-status
|
||||
/// mapping, which both this tag and __mysql rely on identically.
|
||||
///
|
||||
/// Registers itself into Global::imapSessions under sessionid (a
|
||||
/// SEPARATE map from __mysql's Global::sessions - the two backends
|
||||
/// aren't interchangeable and Global::sessions is concretely typed
|
||||
/// __mysql*, not something a second backend could share without
|
||||
/// widening every existing __mysql-only call site), the same way
|
||||
/// __mysql registers into Global::sessions - later __imap* -family
|
||||
/// tags (__imaplist, __imapmessage, __imapflag, __imapdelete) look
|
||||
/// the live connection up by sessionid, mirroring how <sql> finds its
|
||||
/// <database> by sessionid.
|
||||
///
|
||||
/// Connection pooling: a thread_local pool keyed by sessionid+user,
|
||||
/// reused across requests on the same APIServer worker thread (an
|
||||
/// IMAP TCP+TLS+LOGIN round trip is too expensive to redo on every
|
||||
/// AJAX call the webmail UI makes) - directly mirrors __mysql.cpp's
|
||||
/// own thread_local connectionPool, including using a cheap
|
||||
/// keepalive probe (NOOP, IMAP's equivalent of mysql_ping()) to
|
||||
/// detect and discard a connection the server itself already dropped
|
||||
/// rather than handing a dead socket to the first real command.
|
||||
///
|
||||
|
||||
class __imap : public Tag {
|
||||
|
||||
public:
|
||||
__imap(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
~__imap();
|
||||
|
||||
// Each returns a complete, ready-to-emit JSON value (object or
|
||||
// array) - the __imap*-family wrapper tags (__imaplist.cpp etc.)
|
||||
// just write whatever this returns straight into their own `out`,
|
||||
// the same one-call-does-everything shape __sql's query() call
|
||||
// has relative to <sql>.
|
||||
/// offset counts back from the newest message (0 = the newest
|
||||
/// page); the returned JSON is {"total":N,"messages":[...]}.
|
||||
coreutils::MString listMessages(const std::string &folder, int limit, int offset);
|
||||
coreutils::MString searchMessages(const std::string &folder, const std::string &query);
|
||||
coreutils::MString fetchMessage(const std::string &folder, uint32_t uid);
|
||||
coreutils::MString setFlag(const std::string &folder, uint32_t uid, const std::string &flag, bool add);
|
||||
coreutils::MString deleteMessage(const std::string &folder, uint32_t uid);
|
||||
coreutils::MString moveMessage(const std::string &folder, uint32_t uid, const std::string &destFolder);
|
||||
// Permanently empties an entire folder - every message, not one at
|
||||
// a time. "1:*" is IMAP's standard UID-range syntax for "every UID
|
||||
// in the selected mailbox" (well-defined and a no-op, not an error,
|
||||
// on an already-empty folder - verified directly against
|
||||
// BARANTMail rather than assumed from the RFC), so this is a
|
||||
// single mark-all-deleted STORE plus one EXPUNGE, not a loop over
|
||||
// deleteMessage() - the whole point is one IMAP round trip instead
|
||||
// of one per message.
|
||||
coreutils::MString emptyFolder(const std::string &folder);
|
||||
coreutils::MString folderCounts();
|
||||
|
||||
coreutils::MString sessionId;
|
||||
|
||||
private:
|
||||
SSL_CTX *ctx = nullptr;
|
||||
SSL *ssl = nullptr;
|
||||
int fd = -1;
|
||||
int tagCounter = 0;
|
||||
std::string recvBuffer;
|
||||
size_t recvPos = 0;
|
||||
std::string selectedFolder;
|
||||
|
||||
std::string nextTag();
|
||||
void sendLine(const std::string &line);
|
||||
char readByte();
|
||||
// Reads one IMAP response line, INCLUDING any literal {n} content
|
||||
// that line announces (rejoined into the same returned string,
|
||||
// separated by "\r\n" markers) - see the .cpp for the full
|
||||
// rationale; this is a pragmatic, purpose-built reader for the
|
||||
// specific, known response shapes this client's own requests
|
||||
// provoke from BARANTMail (whose own FETCH implementation - built
|
||||
// earlier this same session - always uses literals for content,
|
||||
// never quoted strings), not a fully general IMAP parser.
|
||||
std::string readResponseLine();
|
||||
// Reads response lines until the tagged completion line for `tag`
|
||||
// (built earlier via nextTag()) appears; returns every line
|
||||
// (untagged and the final tagged one) collected along the way.
|
||||
// Throws if the tagged line's status isn't OK.
|
||||
std::vector<std::string> readUntilTagged(const std::string &tag);
|
||||
|
||||
bool selectFolderIfNeeded(const std::string &folder);
|
||||
static std::string jsonEscape(const std::string &s);
|
||||
static uint32_t findUidField(const std::string &fetchLine);
|
||||
static std::vector<std::string> findFlagsField(const std::string &fetchLine);
|
||||
static long findSizeField(const std::string &fetchLine);
|
||||
// Extracts the literal content immediately following a
|
||||
// "BODY[...]" (or "BODY[...]<n>") marker in an already-
|
||||
// literal-rejoined response line - see readResponseLine()'s own
|
||||
// doc comment for the "\r\n"-separated rejoining this depends on.
|
||||
static std::string findBodyLiteral(const std::string &fetchLine);
|
||||
// Shared by listMessages() and searchMessages() - see its own
|
||||
// doc comment in the .cpp.
|
||||
static std::vector<std::string> parseSummaryLines(const std::vector<std::string> &lines);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,163 @@
|
||||
#include "__imapaccounts.h"
|
||||
#include "Base64.h"
|
||||
#include "Exception.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
namespace jet {
|
||||
|
||||
std::string __imapaccounts::jsonEscape(const std::string &s) {
|
||||
std::string out;
|
||||
out.reserve(s.size() + 8);
|
||||
for (unsigned char c : s) {
|
||||
switch (c) {
|
||||
case '"': out += "\\\""; break;
|
||||
case '\\': out += "\\\\"; break;
|
||||
case '\n': out += "\\n"; break;
|
||||
case '\r': continue;
|
||||
case '\t': out += "\\t"; break;
|
||||
default:
|
||||
if (c < 0x20) {
|
||||
char buf[8];
|
||||
snprintf(buf, sizeof(buf), "\\u%04x", c);
|
||||
out += buf;
|
||||
} else {
|
||||
out += (char)c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static std::string trimWhitespace(const std::string &s) {
|
||||
size_t start = s.find_first_not_of(" \t\r\n");
|
||||
if (start == std::string::npos)
|
||||
return std::string();
|
||||
size_t end = s.find_last_not_of(" \t\r\n");
|
||||
return s.substr(start, end - start + 1);
|
||||
}
|
||||
|
||||
std::vector<__imapaccounts::Account> __imapaccounts::decodeList(const std::string &encodedRaw) {
|
||||
std::vector<Account> entries;
|
||||
coreutils::Base64 base64;
|
||||
// The list value round-trips through <eval>/<set> template
|
||||
// captures, which include whatever whitespace/newlines surround
|
||||
// the tag call in the .jet source - trimming here (rather than
|
||||
// insisting every template call site stays whitespace-free) is
|
||||
// the robust fix, since a base64 decoder that stops at the first
|
||||
// invalid character would otherwise silently truncate to nothing
|
||||
// when a stray leading newline precedes real, valid content.
|
||||
std::string encoded = trimWhitespace(encodedRaw);
|
||||
size_t pos = 0;
|
||||
while (pos < encoded.size()) {
|
||||
size_t semi = encoded.find(';', pos);
|
||||
std::string entry = (semi == std::string::npos) ? encoded.substr(pos) : encoded.substr(pos, semi - pos);
|
||||
pos = (semi == std::string::npos) ? encoded.size() : semi + 1;
|
||||
entry = trimWhitespace(entry);
|
||||
if (entry.empty())
|
||||
continue;
|
||||
size_t colon1 = entry.find(':');
|
||||
if (colon1 == std::string::npos)
|
||||
continue;
|
||||
size_t colon2 = entry.find(':', colon1 + 1);
|
||||
if (colon2 == std::string::npos)
|
||||
continue;
|
||||
std::string hostB64 = trimWhitespace(entry.substr(0, colon1));
|
||||
std::string userB64 = trimWhitespace(entry.substr(colon1 + 1, colon2 - colon1 - 1));
|
||||
std::string passB64 = trimWhitespace(entry.substr(colon2 + 1));
|
||||
Account account;
|
||||
account.host = base64.decode(hostB64).str();
|
||||
account.user = base64.decode(userB64).str();
|
||||
account.password = base64.decode(passB64).str();
|
||||
entries.push_back(account);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
std::string __imapaccounts::encodeList(const std::vector<Account> &entries) {
|
||||
coreutils::Base64 base64;
|
||||
std::string result;
|
||||
for (size_t i = 0; i < entries.size(); i++) {
|
||||
if (i > 0)
|
||||
result += ";";
|
||||
std::string host = entries[i].host;
|
||||
std::string user = entries[i].user;
|
||||
std::string password = entries[i].password;
|
||||
result += base64.encode(host).str();
|
||||
result += ":";
|
||||
result += base64.encode(user).str();
|
||||
result += ":";
|
||||
result += base64.encode(password).str();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__imapaccounts::__imapaccounts(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
std::string action = trimWhitespace(resolveKeyword("action").str());
|
||||
std::string listStr = resolveKeyword("list").str();
|
||||
auto entries = decodeList(listStr);
|
||||
|
||||
if (action == "add") {
|
||||
std::string host = trimWhitespace(resolveKeyword("host").str());
|
||||
std::string user = trimWhitespace(resolveKeyword("user").str());
|
||||
std::string password = trimWhitespace(resolveKeyword("password").str());
|
||||
for (size_t i = 0; i < entries.size(); i++) {
|
||||
if (entries[i].user == user) {
|
||||
entries.erase(entries.begin() + (long)i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Account account;
|
||||
account.host = host;
|
||||
account.user = user;
|
||||
account.password = password;
|
||||
entries.push_back(account);
|
||||
out = coreutils::MString(encodeList(entries));
|
||||
} else if (action == "remove") {
|
||||
std::string user = trimWhitespace(resolveKeyword("user").str());
|
||||
for (size_t i = 0; i < entries.size(); i++) {
|
||||
if (entries[i].user == user) {
|
||||
entries.erase(entries.begin() + (long)i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
out = coreutils::MString(encodeList(entries));
|
||||
} else if (action == "getpassword") {
|
||||
std::string user = trimWhitespace(resolveKeyword("user").str());
|
||||
std::string password;
|
||||
for (size_t i = 0; i < entries.size(); i++) {
|
||||
if (entries[i].user == user) {
|
||||
password = entries[i].password;
|
||||
break;
|
||||
}
|
||||
}
|
||||
out = coreutils::MString(password);
|
||||
} else if (action == "gethost") {
|
||||
std::string user = trimWhitespace(resolveKeyword("user").str());
|
||||
std::string host;
|
||||
for (size_t i = 0; i < entries.size(); i++) {
|
||||
if (entries[i].user == user) {
|
||||
host = entries[i].host;
|
||||
break;
|
||||
}
|
||||
}
|
||||
out = coreutils::MString(host);
|
||||
} else if (action == "firstuser") {
|
||||
out = coreutils::MString(entries.empty() ? std::string() : entries[0].user);
|
||||
} else if (action == "list") {
|
||||
std::string active = resolveKeyword("active").str();
|
||||
std::string json = "{\"accounts\":[";
|
||||
for (size_t i = 0; i < entries.size(); i++) {
|
||||
if (i > 0)
|
||||
json += ",";
|
||||
json += "\"" + jsonEscape(entries[i].user) + "\"";
|
||||
}
|
||||
json += "],\"active\":\"" + jsonEscape(active) + "\"}";
|
||||
out = coreutils::MString(json);
|
||||
} else {
|
||||
throw coreutils::Exception("imapaccounts: unknown action \"" + action + "\"", __FILE__, __LINE__, 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#ifndef ____imapaccounts_h__
|
||||
# define ____imapaccounts_h__
|
||||
|
||||
# include "Tag.h"
|
||||
# include "ZString.h"
|
||||
# include "MString.h"
|
||||
# include <string>
|
||||
# include <utility>
|
||||
# include <vector>
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imapaccounts action="add|remove|getpassword|gethost|firstuser|list"
|
||||
/// list="$[@_imap_accounts]" host="..." user="..." password="...">
|
||||
///
|
||||
/// Pure list-transform tag (no session-variable access of its own,
|
||||
/// no IMAP connection) that manages the multi-account list webmail
|
||||
/// keeps in the single session variable "_imap_accounts" - the .jet
|
||||
/// route wraps each call in <eval name="_imap_accounts"> itself and
|
||||
/// <set>s it back, the same separation-of-concerns every other
|
||||
/// session variable in this codebase already uses (this tag never
|
||||
/// touches Global's session-variable map directly).
|
||||
///
|
||||
/// The list's own on-the-wire encoding (semicolon-separated
|
||||
/// "base64(host):base64(user):base64(password)" entries) is private
|
||||
/// to this tag - callers only ever pass the whole `list` value back
|
||||
/// in verbatim and use the returned value the same way, so the
|
||||
/// choice of delimiter can't collide with any real username or
|
||||
/// password character. Each account can live on its own IMAP server
|
||||
/// (see the <imap>/<imaplist>/etc. tags' own optional host/port
|
||||
/// keywords), not just the one fixed host in email.cfg.
|
||||
///
|
||||
/// action="add": upserts host/user/password (removing any existing
|
||||
/// entry for the same user first, so reconnecting with a changed
|
||||
/// password or server updates it) - returns the updated encoded list.
|
||||
/// action="remove": drops the entry for user, if present - returns
|
||||
/// the updated encoded list.
|
||||
/// action="getpassword": returns the stored password for user, or
|
||||
/// an empty string if not present.
|
||||
/// action="gethost": returns the stored host for user, or an empty
|
||||
/// string if not present.
|
||||
/// action="firstuser": returns the first entry's username, or an
|
||||
/// empty string if the list is empty.
|
||||
/// action="list": returns JSON ({"accounts":[...],"active":"..."})
|
||||
/// - the one client-facing action; "active" echoes the `active`
|
||||
/// keyword (typically $[@_imap_user]) back verbatim so the sidebar
|
||||
/// can highlight the current one, and never includes any password or
|
||||
/// host (unchanged shape from before per-account hosts existed -
|
||||
/// nothing client-side needs the host to switch between already-
|
||||
/// connected accounts).
|
||||
///
|
||||
class __imapaccounts : public Tag {
|
||||
|
||||
struct Account {
|
||||
std::string host, user, password;
|
||||
};
|
||||
|
||||
public:
|
||||
__imapaccounts(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
private:
|
||||
static std::vector<Account> decodeList(const std::string &encoded);
|
||||
static std::string encodeList(const std::vector<Account> &entries);
|
||||
static std::string jsonEscape(const std::string &s);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "__imapdelete.h"
|
||||
#include "Exception.h"
|
||||
#include "__imap.h"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__imapdelete::__imapdelete(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if (!global.imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
|
||||
|
||||
std::string folder = resolveKeyword("folder").str();
|
||||
if (folder.empty())
|
||||
folder = "INBOX";
|
||||
|
||||
if (!keywordDefined("uid"))
|
||||
throw coreutils::Exception("imapdelete tag must have uid defined.", __FILE__, __LINE__, 400);
|
||||
uint32_t uid = (uint32_t)strtoul(resolveKeyword("uid").str().c_str(), nullptr, 10);
|
||||
|
||||
out = global.getImapSession(sessionId)->deleteMessage(folder, uid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef ____imapdelete_h__
|
||||
# define ____imapdelete_h__
|
||||
|
||||
# include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imapdelete sessionid="" folder="INBOX" uid="123">
|
||||
///
|
||||
/// Self-closing tag - marks \Deleted and EXPUNGEs one message,
|
||||
/// writes {"ok":true|false} into `out`. See __imaplist.h's doc
|
||||
/// comment for how `out` reaches the real response body.
|
||||
///
|
||||
|
||||
class __imapdelete : public Tag {
|
||||
|
||||
public:
|
||||
__imapdelete(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "__imapemptyfolder.h"
|
||||
#include "Exception.h"
|
||||
#include "__imap.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
__imapemptyfolder::__imapemptyfolder(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if (!global.imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
|
||||
|
||||
// Unlike __imapdelete (one message - low blast radius even on a
|
||||
// wrong default), this permanently destroys an entire folder's
|
||||
// contents - no silent "defaults to INBOX" here. A missing/blank
|
||||
// folder attribute is refused outright rather than risked.
|
||||
if (!keywordDefined("folder"))
|
||||
throw coreutils::Exception("imapemptyfolder tag must have folder defined.", __FILE__, __LINE__, 400);
|
||||
std::string folder = resolveKeyword("folder").str();
|
||||
if (folder.empty())
|
||||
throw coreutils::Exception("imapemptyfolder tag must have folder defined.", __FILE__, __LINE__, 400);
|
||||
|
||||
out = global.getImapSession(sessionId)->emptyFolder(folder);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef ____imapemptyfolder_h__
|
||||
# define ____imapemptyfolder_h__
|
||||
|
||||
# include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imapemptyfolder sessionid="" folder="Trash">
|
||||
///
|
||||
/// Self-closing tag - permanently deletes every message in the given
|
||||
/// folder (mark-all-\Deleted + one EXPUNGE, not a per-message loop),
|
||||
/// writes {"ok":true|false} into `out`. See __imaplist.h's doc
|
||||
/// comment for how `out` reaches the real response body.
|
||||
///
|
||||
|
||||
class __imapemptyfolder : public Tag {
|
||||
|
||||
public:
|
||||
__imapemptyfolder(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "__imapflag.h"
|
||||
#include "Exception.h"
|
||||
#include "__imap.h"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__imapflag::__imapflag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if (!global.imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
|
||||
|
||||
std::string folder = resolveKeyword("folder").str();
|
||||
if (folder.empty())
|
||||
folder = "INBOX";
|
||||
|
||||
if (!keywordDefined("uid"))
|
||||
throw coreutils::Exception("imapflag tag must have uid defined.", __FILE__, __LINE__, 400);
|
||||
uint32_t uid = (uint32_t)strtoul(resolveKeyword("uid").str().c_str(), nullptr, 10);
|
||||
|
||||
if (!keywordDefined("flag"))
|
||||
throw coreutils::Exception("imapflag tag must have flag defined.", __FILE__, __LINE__, 400);
|
||||
std::string flag = resolveKeyword("flag").str();
|
||||
|
||||
std::string setStr = resolveKeyword("set").str();
|
||||
bool add = setStr.empty() || setStr == "yes" || setStr == "true";
|
||||
|
||||
out = global.getImapSession(sessionId)->setFlag(folder, uid, flag, add);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef ____imapflag_h__
|
||||
# define ____imapflag_h__
|
||||
|
||||
# include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imapflag sessionid="" folder="INBOX" uid="123" flag="\Seen" set="yes">
|
||||
///
|
||||
/// Self-closing tag - STOREs (adds, or removes when set="no") a
|
||||
/// single IMAP flag on one message, writes {"ok":true|false} into
|
||||
/// `out`. See __imaplist.h's doc comment for how `out` reaches the
|
||||
/// real response body.
|
||||
///
|
||||
|
||||
class __imapflag : public Tag {
|
||||
|
||||
public:
|
||||
__imapflag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "__imapfolders.h"
|
||||
#include "Exception.h"
|
||||
#include "__imap.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
__imapfolders::__imapfolders(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if (!global.imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
|
||||
|
||||
out = global.getImapSession(sessionId)->folderCounts();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef ____imapfolders_h__
|
||||
# define ____imapfolders_h__
|
||||
|
||||
# include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imapfolders sessionid="">
|
||||
///
|
||||
/// Self-closing tag - writes {"Inbox":{"messages":n,"unseen":n},
|
||||
/// "Spam":{...},"Trash":{...}} into `out` (see
|
||||
/// __imap::folderCounts()'s own doc comment for why it's this fixed
|
||||
/// 3-folder set specifically). See __imaplist.h's doc comment for
|
||||
/// how `out` reaches the real response body.
|
||||
///
|
||||
|
||||
class __imapfolders : public Tag {
|
||||
|
||||
public:
|
||||
__imapfolders(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "__imaplist.h"
|
||||
#include "Exception.h"
|
||||
#include "__imap.h"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__imaplist::__imaplist(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if (!global.imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
|
||||
|
||||
std::string folder = resolveKeyword("folder").str();
|
||||
if (folder.empty())
|
||||
folder = "INBOX";
|
||||
|
||||
std::string limitStr = resolveKeyword("limit").str();
|
||||
int limit = limitStr.empty() ? 50 : atoi(limitStr.c_str());
|
||||
if (limit <= 0)
|
||||
limit = 50;
|
||||
|
||||
std::string offsetStr = resolveKeyword("offset").str();
|
||||
int offset = offsetStr.empty() ? 0 : atoi(offsetStr.c_str());
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
|
||||
out = global.getImapSession(sessionId)->listMessages(folder, limit, offset);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef ____imaplist_h__
|
||||
# define ____imaplist_h__
|
||||
|
||||
# include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imaplist sessionid="" folder="INBOX" limit="50">
|
||||
///
|
||||
/// Self-closing tag (no container) - writes a JSON array of message
|
||||
/// summaries for `folder`, newest first, straight into `out`, the
|
||||
/// same way any other self-closing value tag with default
|
||||
/// output=true/evaluate=true does: Tag::~Tag() copies `out` into the
|
||||
/// caller's parentOut verbatim (Tag::copyContainer() is a raw byte
|
||||
/// copy, no re-evaluation - see Tag.cpp - so literal "$"/"["/"<" in
|
||||
/// real email subjects pass through unmolested; __imap::jsonEscape()
|
||||
/// already handled quote/backslash/control-char JSON-escaping).
|
||||
///
|
||||
|
||||
class __imaplist : public Tag {
|
||||
|
||||
public:
|
||||
__imaplist(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "__imapmessage.h"
|
||||
#include "Exception.h"
|
||||
#include "__imap.h"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__imapmessage::__imapmessage(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if (!global.imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
|
||||
|
||||
std::string folder = resolveKeyword("folder").str();
|
||||
if (folder.empty())
|
||||
folder = "INBOX";
|
||||
|
||||
if (!keywordDefined("uid"))
|
||||
throw coreutils::Exception("imapmessage tag must have uid defined.", __FILE__, __LINE__, 400);
|
||||
uint32_t uid = (uint32_t)strtoul(resolveKeyword("uid").str().c_str(), nullptr, 10);
|
||||
|
||||
out = global.getImapSession(sessionId)->fetchMessage(folder, uid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef ____imapmessage_h__
|
||||
# define ____imapmessage_h__
|
||||
|
||||
# include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imapmessage sessionid="" folder="INBOX" uid="123">
|
||||
///
|
||||
/// Self-closing tag - writes a single JSON message object (headers +
|
||||
/// text body) into `out`. See __imaplist.h's doc comment for how
|
||||
/// `out` reaches the real response body.
|
||||
///
|
||||
|
||||
class __imapmessage : public Tag {
|
||||
|
||||
public:
|
||||
__imapmessage(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "__imapmove.h"
|
||||
#include "Exception.h"
|
||||
#include "__imap.h"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__imapmove::__imapmove(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if (!global.imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
|
||||
|
||||
std::string folder = resolveKeyword("folder").str();
|
||||
if (folder.empty())
|
||||
folder = "INBOX";
|
||||
|
||||
if (!keywordDefined("uid"))
|
||||
throw coreutils::Exception("imapmove tag must have uid defined.", __FILE__, __LINE__, 400);
|
||||
uint32_t uid = (uint32_t)strtoul(resolveKeyword("uid").str().c_str(), nullptr, 10);
|
||||
|
||||
if (!keywordDefined("destfolder"))
|
||||
throw coreutils::Exception("imapmove tag must have destfolder defined.", __FILE__, __LINE__, 400);
|
||||
std::string destFolder = resolveKeyword("destfolder").str();
|
||||
|
||||
out = global.getImapSession(sessionId)->moveMessage(folder, uid, destFolder);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef ____imapmove_h__
|
||||
# define ____imapmove_h__
|
||||
|
||||
# include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imapmove sessionid="" folder="INBOX" uid="123" destfolder="Trash">
|
||||
///
|
||||
/// Self-closing tag - moves one message into destfolder (COPY there,
|
||||
/// then \Deleted + EXPUNGE from the original folder, the standard
|
||||
/// pre-RFC6851 two-step "move" every IMAP client used before the
|
||||
/// MOVE extension existed - see __imap::moveMessage()'s own doc
|
||||
/// comment for why this server doesn't just speak that extension
|
||||
/// directly). Writes {"ok":true|false} into `out`, same convention
|
||||
/// as __imapdelete/__imapflag.
|
||||
///
|
||||
|
||||
class __imapmove : public Tag {
|
||||
|
||||
public:
|
||||
__imapmove(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "__imapsearch.h"
|
||||
#include "Exception.h"
|
||||
#include "__imap.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
__imapsearch::__imapsearch(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if (!global.imapSessionExists(sessionId))
|
||||
throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502);
|
||||
|
||||
std::string folder = resolveKeyword("folder").str();
|
||||
if (folder.empty())
|
||||
folder = "INBOX";
|
||||
|
||||
std::string query = resolveKeyword("query").str();
|
||||
|
||||
out = global.getImapSession(sessionId)->searchMessages(folder, query);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef ____imapsearch_h__
|
||||
# define ____imapsearch_h__
|
||||
|
||||
# include "Tag.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <imapsearch sessionid="" folder="INBOX" query="text">
|
||||
///
|
||||
/// Self-closing tag - writes a JSON array of message summaries
|
||||
/// (same shape as <imaplist>) for every message in `folder` whose
|
||||
/// From, Subject, or body matches `query` (see
|
||||
/// __imap::searchMessages()'s own doc comment), newest first,
|
||||
/// straight into `out`.
|
||||
///
|
||||
|
||||
class __imapsearch : public Tag {
|
||||
|
||||
public:
|
||||
__imapsearch(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,33 +1,102 @@
|
||||
#include "__include.h"
|
||||
#include "Exception.h"
|
||||
#include "File.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace jet {
|
||||
|
||||
namespace {
|
||||
struct CachedInclude {
|
||||
std::string content;
|
||||
time_t mtime;
|
||||
};
|
||||
// Persistent, per-worker-thread cache of <include> file contents,
|
||||
// keyed by resolved filename. Real content depends on this
|
||||
// constantly through custom tag bodies that jetc's own compile-
|
||||
// time <include>-inlining doesn't reach (only the top-level .jet
|
||||
// source's own includes get compiled in) - mainpagetemplate.temp
|
||||
// alone pulls in login.menu/menu.bar/opensource.menu/cart.menu/
|
||||
// sessionvar.menu, all previously re-read from disk on every
|
||||
// single request even though the files are 100% static between
|
||||
// edits. Invalidated via mtime comparison (a stat() call, cheap
|
||||
// relative to a full read()) so a live edit still takes effect on
|
||||
// the very next request - matching the workflow already relied on
|
||||
// all session of editing .tag/.temp/.menu content directly and
|
||||
// seeing it live without a rebuild.
|
||||
thread_local std::unordered_map<std::string, CachedInclude> includeCache;
|
||||
}
|
||||
|
||||
__include::__include(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
if(!keywordDefined("file"))
|
||||
throw coreutils::Exception("file keyword must be specified.");
|
||||
if(hasContainer)
|
||||
throw coreutils::Exception("include tag should not have a container.");
|
||||
hasContainer = true;
|
||||
coreutils::File file(resolveKeyword("file"));
|
||||
file.read();
|
||||
container = file.asZString();
|
||||
coreutils::MString includeFileName = resolveKeyword("file");
|
||||
std::string fileNameKey = includeFileName.str();
|
||||
|
||||
struct stat st;
|
||||
bool haveStat = (stat(fileNameKey.c_str(), &st) == 0);
|
||||
|
||||
auto cached = includeCache.find(fileNameKey);
|
||||
if(cached != includeCache.end() && haveStat && cached->second.mtime == st.st_mtime) {
|
||||
container = coreutils::ZString(cached->second.content.data(), cached->second.content.length());
|
||||
} else {
|
||||
coreutils::File file(includeFileName);
|
||||
file.read();
|
||||
if(haveStat) {
|
||||
CachedInclude &entry = includeCache[fileNameKey];
|
||||
entry.content = file.asString();
|
||||
entry.mtime = st.st_mtime;
|
||||
container = coreutils::ZString(entry.content.data(), entry.content.length());
|
||||
} else {
|
||||
// Couldn't stat the file (unusual - e.g. a race with deletion) -
|
||||
// don't cache something we can't validate the freshness of,
|
||||
// just render this one read directly, matching the pre-cache
|
||||
// behavior exactly for this edge case.
|
||||
container = file.asZString();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
processContainer(container);
|
||||
}
|
||||
catch(coreutils::Exception e) {
|
||||
container.setCursor(global.errorCursor);
|
||||
container.moveBackToLineStart();
|
||||
std::cout << "-----------------------------" << std::endl;
|
||||
std::cout << "Error in included script '" << variables["file"] << "' at line " << container.getLineNumberAtCursor() << std::endl;
|
||||
std::cout << "Error text: " << e.text << std::endl;
|
||||
std::cout << "-----------------------------" << std::endl;
|
||||
std::cout << container.parsed() << std::endl;
|
||||
std::cout << "******** Error caught: " << e.text << std::endl;
|
||||
std::cout << container.unparsed() << std::endl;
|
||||
// global.errorCursor is whatever cursor was active in whichever
|
||||
// ZString buffer was being parsed at the moment the ORIGINAL
|
||||
// exception was thrown - not necessarily this include's own
|
||||
// `container` buffer at all (e.g. a keyword-resolution error
|
||||
// happening while interpreting a completely different .temp
|
||||
// file's own text). setCursor() on a pointer outside container's
|
||||
// own [data, data+length] range throws "Cursor out of range on
|
||||
// setCursor." - and since that happens INSIDE this diagnostic-
|
||||
// only "show a nice line number" block, it was replacing the
|
||||
// real error (e.text) with that unrelated cursor-range message
|
||||
// before it ever reached the caller, making every real error
|
||||
// from inside an <include> impossible to see. This is purely
|
||||
// diagnostic output - if it can't compute a line number, fall
|
||||
// back to printing the real error text without one rather than
|
||||
// losing it entirely.
|
||||
try {
|
||||
container.setCursor(global.errorCursor);
|
||||
container.moveBackToLineStart();
|
||||
std::cout << "-----------------------------" << std::endl;
|
||||
std::cout << "Error in included script '" << variables["file"] << "' at line " << container.getLineNumberAtCursor() << std::endl;
|
||||
std::cout << "Error text: " << e.text << std::endl;
|
||||
std::cout << "-----------------------------" << std::endl;
|
||||
std::cout << container.parsed() << std::endl;
|
||||
std::cout << "******** Error caught: " << e.text << std::endl;
|
||||
std::cout << container.unparsed() << std::endl;
|
||||
} catch(coreutils::Exception &) {
|
||||
std::cout << "-----------------------------" << std::endl;
|
||||
std::cout << "Error in included script '" << variables["file"] << "' (line number unavailable - error originated outside this include's own content)" << std::endl;
|
||||
std::cout << "Error text: " << e.text << std::endl;
|
||||
std::cout << "-----------------------------" << std::endl;
|
||||
}
|
||||
global.errorCursor = in.getCursor();
|
||||
throw coreutils::Exception("error in included file.");
|
||||
throw coreutils::Exception(e.text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,57 +1,109 @@
|
||||
#include "__jet.h"
|
||||
#include "Exception.h"
|
||||
#include "Global.h"
|
||||
#include "SessionId.h"
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <openssl/ssl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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") == "true")) {
|
||||
if(keywordDefined("cgi") && (resolveKeyword("cgi") == "yes")) {
|
||||
global.cgi = true;
|
||||
|
||||
if(keywordDefined("sessiondir")) {
|
||||
global.session = true;
|
||||
global.cookies = getenv("HTTP_COOKIE");
|
||||
|
||||
// if request_has_cookie then
|
||||
// pull sessionfile from sessiondir.
|
||||
coreutils::MString sessionIdValue;
|
||||
if(global.cookies.data["session"] != NULL) {
|
||||
sessionIdValue = global.cookies.data["session"];
|
||||
// if last activity time is expired then ignore.
|
||||
// follow sessiontimeoutredirecturl.
|
||||
// else
|
||||
unsigned char hashit[64];
|
||||
unsigned char hash[SHA_DIGEST_LENGTH];
|
||||
char hashname[64];
|
||||
sprintf((char *)hashit, "JETSESSION%ld", time(0));
|
||||
SHA1(hashit, strlen((char *)hashit), hash);
|
||||
sprintf(hashname, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||
hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], hash[8], hash[9],
|
||||
hash[10], hash[11], hash[12], hash[13], hash[14], hash[15], hash[16], hash[17], hash[18], hash[19]);
|
||||
coreutils::ZString sessionCookie(hashname);
|
||||
global.headers["Set-Cookie"] << "session=" << sessionCookie;
|
||||
if(keywordDefined("sessiontimeout")) {
|
||||
time_t timeout = time(0) + keywords["sessiontimeout"].asInteger();
|
||||
} else {
|
||||
SessionId sessionId;
|
||||
// A 160-bit CSPRNG value colliding with an existing session file
|
||||
// is astronomically unlikely, but cheap to guard against outright
|
||||
// rather than trust the probability - regenerate on an actual
|
||||
// collision instead of ever reusing another session's file.
|
||||
int sessionIdAttempts = 0;
|
||||
while(true) {
|
||||
coreutils::MString candidatePath;
|
||||
candidatePath << resolveKeyword("sessiondir") << "/" << sessionId << ".json";
|
||||
if(access(candidatePath.c_str(), F_OK) != 0)
|
||||
break;
|
||||
if(++sessionIdAttempts >= 5)
|
||||
throw coreutils::Exception("could not generate a unique session id after multiple attempts.");
|
||||
sessionId = SessionId();
|
||||
}
|
||||
global.headers["Set-Cookie"] << "session=" << sessionId;
|
||||
global.cookies.data["session"] = sessionId;
|
||||
sessionIdValue = sessionId;
|
||||
if(keywordDefined("sessiontimeout")) {
|
||||
time_t timeout = time(0) + keywords["sessiontimeout"].asInteger();
|
||||
}
|
||||
// also save last activity time in session file.
|
||||
}
|
||||
|
||||
// also save last activity time in session file.
|
||||
|
||||
// JFile's own RAII behavior (see CoreUtils MFile.cpp) loads
|
||||
// whatever JSON is already at this path, or starts empty if the
|
||||
// file doesn't exist yet (a brand-new session), and writes any
|
||||
// changes back automatically when destroyed - no explicit save
|
||||
// call needed anywhere.
|
||||
coreutils::MString sessionFilePath;
|
||||
sessionFilePath << resolveKeyword("sessiondir");
|
||||
sessionFilePath << "/";
|
||||
sessionFilePath << sessionIdValue;
|
||||
sessionFilePath << ".json";
|
||||
global.sessionFile = new coreutils::JFile(sessionFilePath);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
// find() leaves contentType's own cursor at the match position -
|
||||
// reset it before handing contentType to CGIFormData, whose
|
||||
// startsWith("multipart/form-data")/startsWith("application/...")
|
||||
// checks are cursor-relative and would otherwise silently miss,
|
||||
// falling through to an unrecognized content type that never
|
||||
// parses anything.
|
||||
contentType.reset();
|
||||
|
||||
if(contentType == "multipart/form-data")
|
||||
coreutils::IMFMultipart postdata(0, "");
|
||||
int bodyLength = contentLength.asInteger();
|
||||
global.cgiData = new coreutils::CGIFormData(global.cgiReader, contentType, bodyLength, boundary);
|
||||
|
||||
// else if(contentType == "application/x-www-form-urlencoded")
|
||||
// global.setupFormURLEncoded(postdata);
|
||||
// Feed the request body off stdin in chunks and drive the parser
|
||||
// resumably (the same feed()/doParse() pattern as a socket-fed
|
||||
// StreamReader) rather than blocking to read it all before parsing
|
||||
// starts - keeps memory bounded for large multipart uploads and
|
||||
// exercises the real Parser::Status::INCOMPLETE resumption path.
|
||||
char cgiReadBuf[4096];
|
||||
int cgiBytesRead = 0;
|
||||
coreutils::Parser::Status cgiStatus = coreutils::Parser::Status::INCOMPLETE;
|
||||
while(cgiBytesRead < bodyLength && cgiStatus != coreutils::Parser::Status::COMPLETE) {
|
||||
int want = bodyLength - cgiBytesRead;
|
||||
if(want > (int)sizeof(cgiReadBuf))
|
||||
want = sizeof(cgiReadBuf);
|
||||
int got = ::read(0, cgiReadBuf, want);
|
||||
if(got <= 0)
|
||||
throw coreutils::Exception("CGI request body ended before Content-Length was reached.");
|
||||
cgiBytesRead += got;
|
||||
coreutils::ZString chunk(cgiReadBuf, got);
|
||||
global.cgiReader.feed(chunk);
|
||||
cgiStatus = global.cgiData->doParse();
|
||||
}
|
||||
if(cgiStatus != coreutils::Parser::Status::COMPLETE)
|
||||
throw coreutils::Exception("CGI request body did not parse to completion.");
|
||||
}
|
||||
}
|
||||
processContainer(container);
|
||||
processContainer(container, NULL, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
|
||||
#include "Tag.h"
|
||||
#include "ZString.h"
|
||||
#include "IMFRequest.h"
|
||||
#include "IMFMessage.h"
|
||||
//#include "IMFMessage.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace jet {
|
||||
|
||||
@@ -1,34 +1,150 @@
|
||||
#include "__mysql.h"
|
||||
#include "Exception.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace jet {
|
||||
|
||||
namespace {
|
||||
struct PooledConnection {
|
||||
MYSQL *handle;
|
||||
std::string host, user, database;
|
||||
};
|
||||
// Persistent, per-worker-thread connection cache - reused across
|
||||
// requests instead of a fresh mysql_real_connect() every time.
|
||||
// Safe with no locking: the apiserver's EPoll worker pool is a
|
||||
// fixed set of OS threads for the process's whole life (see
|
||||
// MysqlThreadScope's own doc comment - mysql_thread_init() runs
|
||||
// once per worker thread at thread start), so a thread_local
|
||||
// instance here means a given MYSQL* handle is only ever touched
|
||||
// by the one thread that created it, never concurrently accessed.
|
||||
// Keyed by sessionid, which is how this codebase's own <database>/
|
||||
// <sql>/<ifrow> tags already address a specific connection
|
||||
// (Global::sessions is keyed the same way) - the cached host/user/
|
||||
// database are kept alongside purely as a defensive check that a
|
||||
// reused entry really matches what THIS invocation asked for,
|
||||
// not a real expectation that sessionid is ever reused across
|
||||
// genuinely different backing databases in practice.
|
||||
thread_local std::unordered_map<std::string, PooledConnection> connectionPool;
|
||||
}
|
||||
|
||||
__mysql::__mysql(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
|
||||
|
||||
if(!keywordDefined("host"))
|
||||
throw coreutils::Exception("host must be specified for mysql tag.");
|
||||
if(!keywordDefined("database"))
|
||||
// jet-1.4's <database> spells the same attribute "name" instead of
|
||||
// "database" (e.g. SESSIONCTL.tag's own <sessionctl> definition) -
|
||||
// accept either rather than requiring that real content to change.
|
||||
coreutils::ZString databaseKeyword = keywordDefined("database") ? "database" : "name";
|
||||
if(!keywordDefined(databaseKeyword))
|
||||
throw coreutils::Exception("database must be specified for mysql tag.");
|
||||
if(!keywordDefined("user"))
|
||||
throw coreutils::Exception("user must be specified for mysql tag.");
|
||||
if(!keywordDefined("password"))
|
||||
throw coreutils::Exception("password must be specified for mysql tag.");
|
||||
|
||||
sessionId = keywords[resolveKeyword("sessionid")];
|
||||
// Same double-indirection bug as the host/user/password/database
|
||||
// fix above - resolveKeyword("sessionid") already returns the
|
||||
// resolved VALUE (e.g. "_SESSIONCTL"), so wrapping it in keywords[...]
|
||||
// used that value as a map KEY instead, auto-vivifying an empty
|
||||
// string (no attribute is ever literally named "_SESSIONCTL").
|
||||
// sessionId was therefore always empty regardless of what
|
||||
// sessionid= actually specified - confirmed live via gdb: two
|
||||
// real <mysql>/<database> tags with genuinely different sessionid
|
||||
// values ("" and "_SESSIONCTL") both registered under "", the
|
||||
// second colliding with "sessionid already exists.".
|
||||
sessionId = resolveKeyword("sessionid");
|
||||
|
||||
// mysql_real_connect() returns NULL on failure but does NOT itself
|
||||
// free the handle mysql_init() allocated - the caller is still
|
||||
// expected to mysql_close() that original handle to avoid leaking
|
||||
// it (MySQL C API docs). The previous code overwrote `mysql` with
|
||||
// the connect() return value directly, so on failure the only
|
||||
// pointer to the real handle was lost before ever being freed - a
|
||||
// real leak on every failed connection attempt (this member's
|
||||
// eventual value, NULL, is what a normal ~__mysql() would try to
|
||||
// mysql_close() anyway, which is a safe no-op, but that never even
|
||||
// runs here since the constructor throws below - see the
|
||||
// addSession() comment for why that matters more).
|
||||
// resolveKeyword() already returns the fully-resolved VALUE - the
|
||||
// previous keywords[resolveKeyword("host")] wrapped that resolved
|
||||
// VALUE ("localhost") back into a keywords[] lookup, i.e. used it
|
||||
// as a MAP KEY instead of the value itself. Since no attribute is
|
||||
// ever literally named "localhost"/the real username/etc.,
|
||||
// std::map::operator[] silently auto-vivified an empty MString for
|
||||
// every one of the four parameters - mysql_real_connect() was
|
||||
// therefore always called with host/user/password/database all
|
||||
// empty, regardless of what the tag actually specified. Confirmed
|
||||
// live: MySQL's own error ("Access denied for user 'barant'@'localhost'
|
||||
// (using password: NO)") showed the password was genuinely empty,
|
||||
// not merely wrong.
|
||||
coreutils::MString hostVal = resolveKeyword("host");
|
||||
coreutils::MString userVal = resolveKeyword("user");
|
||||
coreutils::MString passwordVal = resolveKeyword("password");
|
||||
coreutils::MString databaseVal = resolveKeyword(databaseKeyword);
|
||||
|
||||
// Reuse a live connection this same worker thread already holds
|
||||
// for this sessionid, rather than paying mysql_real_connect()'s
|
||||
// full handshake cost on every single request. mysql_ping() is
|
||||
// what makes this safe - it's a genuine round trip to the server,
|
||||
// so a connection MySQL itself already dropped (its own
|
||||
// wait_timeout, or an admin-initiated restart like this project
|
||||
// already lived through once) is detected and discarded here
|
||||
// rather than handed to processContainer() to fail on later.
|
||||
std::string poolKey = sessionId.str();
|
||||
auto pooled = connectionPool.find(poolKey);
|
||||
if(pooled != connectionPool.end() &&
|
||||
pooled->second.host == hostVal.str() &&
|
||||
pooled->second.user == userVal.str() &&
|
||||
pooled->second.database == databaseVal.str()) {
|
||||
if(mysql_ping(pooled->second.handle) == 0) {
|
||||
mysql = pooled->second.handle;
|
||||
} else {
|
||||
mysql_close(pooled->second.handle);
|
||||
connectionPool.erase(pooled);
|
||||
}
|
||||
}
|
||||
|
||||
if(!mysql) {
|
||||
MYSQL *handle = mysql_init(NULL);
|
||||
// Pin the connection character set so <bind>'s client-side
|
||||
// escaping and the server's parsing always agree (<sql> refuses
|
||||
// SET NAMES and friends for the same reason).
|
||||
mysql_options(handle, MYSQL_SET_CHARSET_NAME, "utf8mb4");
|
||||
mysql = mysql_real_connect(handle,
|
||||
hostVal.c_str(),
|
||||
userVal.c_str(),
|
||||
passwordVal.c_str(),
|
||||
databaseVal.c_str(), 0, NULL, 0);
|
||||
|
||||
if(!mysql) {
|
||||
std::string err = mysql_error(handle);
|
||||
mysql_close(handle);
|
||||
throw coreutils::Exception("database connection failed: " + err);
|
||||
}
|
||||
|
||||
connectionPool[poolKey] = PooledConnection{mysql, hostVal.str(), userVal.str(), databaseVal.str()};
|
||||
}
|
||||
|
||||
// Registered only once the connection is confirmed live - a real,
|
||||
// reproducible crash (heap corruption - "free(): invalid pointer"
|
||||
// seen live, then two independent server-hang repros) traced back
|
||||
// to this: addSession() used to run BEFORE the connect attempt, so
|
||||
// a FAILED connection (which throws, right above) left a dangling
|
||||
// `this` pointer registered under sessionId in Global's session
|
||||
// map forever - ~__mysql() (which would normally call
|
||||
// removeSession()) never runs for a constructor that itself threw,
|
||||
// per ordinary C++ rules (only already-completed base-class
|
||||
// subobjects get destroyed during exception unwinding, not the
|
||||
// derived object whose constructor is still executing). The very
|
||||
// next <mysql> tag construction using the same sessionId (e.g. two
|
||||
// product pages with an empty sessionid="" back to back, both
|
||||
// failing the same way) then collided with that stale entry.
|
||||
// Confirmed via a real, deterministic two-request repro before this
|
||||
// fix, and confirmed gone after it.
|
||||
global.addSession(sessionId, this);
|
||||
|
||||
mysql = mysql_init(NULL);
|
||||
mysql = mysql_real_connect(mysql,
|
||||
keywords[resolveKeyword("host")].c_str(),
|
||||
keywords[resolveKeyword("user")].c_str(),
|
||||
keywords[resolveKeyword("password")].c_str(),
|
||||
keywords[resolveKeyword("database")].c_str(), 0, NULL, 0);
|
||||
|
||||
if(!mysql)
|
||||
throw coreutils::Exception("database and host parameters are not valid.");
|
||||
|
||||
processContainer(container);
|
||||
|
||||
}
|
||||
@@ -36,19 +152,78 @@ namespace jet {
|
||||
__mysql::~__mysql() {
|
||||
global.removeSession(sessionId);
|
||||
mysql_free_result(result);
|
||||
mysql_close(mysql);
|
||||
// mysql itself is deliberately NOT closed here anymore - see the
|
||||
// connectionPool doc comment above the constructor. It's owned by
|
||||
// this worker thread's persistent pool now and gets reused by
|
||||
// whatever request this thread handles next, instead of being
|
||||
// torn down and fully reconnected from scratch every time.
|
||||
}
|
||||
|
||||
void __mysql::query(coreutils::MString query) {
|
||||
int rc = mysql_real_query(mysql, query.getData(), query.getLength());
|
||||
// rc was captured but never checked - a genuinely failed query
|
||||
// (syntax error, constraint violation, etc.) fell straight into
|
||||
// the result==NULL branch below, which is ALSO the normal path
|
||||
// for a successful non-SELECT statement (INSERT/UPDATE/DELETE
|
||||
// have no result set to store either). That made every SQL error
|
||||
// in the whole codebase silently indistinguishable from "ran fine,
|
||||
// no rows" - <try>/<catch> around a failing <sql> never caught
|
||||
// anything, since no exception was ever thrown in the first place.
|
||||
// Only rc (mysql_real_query's own success/failure signal) can
|
||||
// actually tell the two cases apart; result's nullness can't.
|
||||
if(rc != 0)
|
||||
throw coreutils::Exception(std::string("mysql query failed: ") + mysql_error(mysql));
|
||||
result = mysql_store_result(mysql);
|
||||
if(result) {
|
||||
row = mysql_fetch_row(result);
|
||||
fieldLength = mysql_fetch_lengths(result);
|
||||
qFields = mysql_num_fields(result);
|
||||
// Built once per query, not once per column LOOKUP - see the
|
||||
// matching comment on getColumnValue() and on fieldIndex's own
|
||||
// declaration in __mysql.h. mysql_fetch_fields() returns the
|
||||
// whole field array in one call (mysql_fetch_field_direct()
|
||||
// looping ix=0..qFields-1, as getColumnValue() used to do on
|
||||
// every single named access, does the exact same work over and
|
||||
// over for a result set whose schema never changes after this
|
||||
// point).
|
||||
fieldIndex.clear();
|
||||
MYSQL_FIELD *fields = mysql_fetch_fields(result);
|
||||
for(unsigned int ix = 0; ix < qFields; ++ix)
|
||||
fieldIndex[std::string(fields[ix].name)] = (int)ix;
|
||||
} else {
|
||||
// A failed/errored query (real content builds one from an unset
|
||||
// $[...] parameter, e.g. "where tasks.id=" with no value - genuine
|
||||
// MySQL syntax error) previously left row/qFields holding whatever
|
||||
// a PRIOR successful query on this same session object had set,
|
||||
// since only the success branch above ever touched them. A later
|
||||
// getColumnValue() call then looped 0..qFields (stale, nonzero)
|
||||
// calling mysql_fetch_field_direct() against this NULL `result` -
|
||||
// segfaulting (confirmed via gdb: SIGSEGV in
|
||||
// mysql_fetch_field_direct, called from getColumnValue) instead of
|
||||
// reaching the "column does not exist in session result." the
|
||||
// caller already throws/catches for a genuinely missing column.
|
||||
// Resetting both here makes a failed query present as "no row, no
|
||||
// columns" - clean and consistent regardless of what ran before it
|
||||
// on this session.
|
||||
row = NULL;
|
||||
qFields = 0;
|
||||
fieldIndex.clear();
|
||||
}
|
||||
}
|
||||
|
||||
std::string __mysql::escapeString(const std::string &value) {
|
||||
std::string to(value.size() * 2 + 1, '\0');
|
||||
unsigned long len = mysql_real_escape_string_quote(mysql, to.data(), value.data(), value.size(), '\'');
|
||||
if(len == (unsigned long)-1)
|
||||
throw coreutils::Exception("sql: bind value could not be escaped.");
|
||||
to.resize(len);
|
||||
return to;
|
||||
}
|
||||
|
||||
bool __mysql::noBackslashEscapes() {
|
||||
return (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) != 0;
|
||||
}
|
||||
|
||||
void __mysql::nextRow() {
|
||||
row = mysql_fetch_row(result);
|
||||
fieldLength = mysql_fetch_lengths(result);
|
||||
@@ -63,25 +238,51 @@ namespace jet {
|
||||
if(column == "?#") {
|
||||
nbrOfColumns = (int)qFields;
|
||||
return nbrOfColumns;
|
||||
} else if(column.ifNext("#")) {
|
||||
} else if(column.ifNext("#") || column.ifNext("?")) {
|
||||
// "#N"/"?N" (column name at 1-based position N) are the same
|
||||
// jet-1.4 syntax under two different prefixes - real, unmodified
|
||||
// 1.4 content uses both (barant.tag's own <showtable> definition
|
||||
// writes $[?$[index]], never $[#$[index]]) - confirmed via a real
|
||||
// repro: admin.page's own Users/Products tables rendered every
|
||||
// column header and cell completely blank, since "?N" fell all
|
||||
// the way through to the ordinary column-VALUE lookup below
|
||||
// (nothing named "?3" exists in the row) and read as empty rather
|
||||
// than as "the name of column 3", per the jet-1.4-fallback #2
|
||||
// empty-string-on-missing-column behavior elsewhere in this
|
||||
// codebase (see Tag.cpp).
|
||||
if(column.eod()) {
|
||||
nbrOfRows = (int)mysql_num_rows(result);
|
||||
return nbrOfRows;
|
||||
} else {
|
||||
std::cout << "[" << column.unparsed() << "]" << std::endl;
|
||||
int index = column.asInteger();
|
||||
std::cout << "integer: " << index << std::endl;
|
||||
field = mysql_fetch_field_direct(result, index - 1);
|
||||
return coreutils::ZString(field->name);
|
||||
}
|
||||
}
|
||||
|
||||
for(int ix = 0; ix < qFields; ++ix) {
|
||||
field = mysql_fetch_field_direct(result, ix);
|
||||
if(column.equals((char *)field->name)) {
|
||||
return coreutils::ZString(row[ix], fieldLength[ix]);
|
||||
}
|
||||
}
|
||||
// A query that ran successfully but matched zero rows (a real,
|
||||
// valid query - e.g. cart.page's own aggregate/JOIN query against
|
||||
// an empty cart session - not a failed one, see query()'s own
|
||||
// row=NULL/qFields=0 reset above for that separate case) leaves
|
||||
// qFields correctly reflecting the real schema but `row` NULL.
|
||||
// The loop below finds a genuine matching column name and then
|
||||
// dereferences row[ix] - segfaulting (confirmed via gdb: SIGSEGV
|
||||
// right here) instead of reaching a catchable error. Reusing the
|
||||
// same "column does not exist" exception the loop's own fallthrough
|
||||
// already throws - no current row means no column value is
|
||||
// obtainable either way, and callers already expect and catch
|
||||
// this exact exception.
|
||||
if(!row)
|
||||
throw coreutils::Exception("column does not exist in session result.");
|
||||
|
||||
// O(1) against the map query() already built for this result set,
|
||||
// instead of re-deriving field metadata (mysql_fetch_field_direct,
|
||||
// a real MySQL C API call) and string-comparing column names one
|
||||
// by one on every single named access - see fieldIndex's own doc
|
||||
// comment in __mysql.h for the full story.
|
||||
auto it = fieldIndex.find(column.str());
|
||||
if(it != fieldIndex.end())
|
||||
return coreutils::ZString(row[it->second], fieldLength[it->second]);
|
||||
throw coreutils::Exception("column does not exist in session result.");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "ZString.h"
|
||||
#include "MString.h"
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
namespace jet {
|
||||
@@ -20,14 +22,37 @@ namespace jet {
|
||||
bool hasRow();
|
||||
coreutils::ZString getColumnValue(coreutils::ZString column);
|
||||
|
||||
// Body of a single-quoted SQL string literal for this connection
|
||||
// (mysql_real_escape_string_quote: uses the connection's character
|
||||
// set and honours NO_BACKSLASH_ESCAPES). Used by <bind>.
|
||||
std::string escapeString(const std::string &value);
|
||||
// True while the session's sql_mode includes NO_BACKSLASH_ESCAPES.
|
||||
bool noBackslashEscapes();
|
||||
|
||||
private:
|
||||
MYSQL *mysql;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
unsigned long *fieldLength;
|
||||
unsigned int qFields;
|
||||
// Explicitly initialized - result/row/fieldLength were otherwise
|
||||
// left as garbage stack values until query() first ran. A
|
||||
// <mysql>...</mysql> block that connects successfully but never
|
||||
// runs a <sql> query inside it (e.g. just a connectivity check)
|
||||
// would previously reach ~__mysql()'s mysql_free_result(result)
|
||||
// with an uninitialized pointer - real undefined behavior, found
|
||||
// while root-causing a live crash in a related part of this same
|
||||
// class's constructor.
|
||||
MYSQL *mysql = NULL;
|
||||
MYSQL_RES *result = NULL;
|
||||
MYSQL_ROW row = NULL;
|
||||
unsigned long *fieldLength = NULL;
|
||||
unsigned int qFields = 0;
|
||||
coreutils::MString sessionId;
|
||||
|
||||
// Column-name -> row[] index, built once per query() call (see its
|
||||
// own comment) instead of getColumnValue() re-deriving it via a
|
||||
// fresh mysql_fetch_field_direct() linear scan on every single
|
||||
// named lookup - a template reading N columns off one row used to
|
||||
// pay that scan N times over, even though the schema is fixed for
|
||||
// the lifetime of one result set.
|
||||
std::unordered_map<std::string, int> fieldIndex;
|
||||
|
||||
coreutils::MString nbrOfRows = "0";
|
||||
coreutils::MString nbrOfColumns = "0";
|
||||
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
#include "__smtpsend.h"
|
||||
#include "Exception.h"
|
||||
#include "JFile.h"
|
||||
#include "Base64.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
namespace jet {
|
||||
|
||||
void __smtpsend::sendLine(const std::string &line) {
|
||||
std::string data = line + "\r\n";
|
||||
size_t sent = 0;
|
||||
while (sent < data.size()) {
|
||||
int n = SSL_write(ssl, data.data() + sent, (int)(data.size() - sent));
|
||||
if (n <= 0)
|
||||
throw coreutils::Exception("smtpsend: write failed", __FILE__, __LINE__, 502);
|
||||
sent += (size_t)n;
|
||||
}
|
||||
}
|
||||
|
||||
char __smtpsend::readByte() {
|
||||
if (recvPos >= recvBuffer.size()) {
|
||||
char buf[4096];
|
||||
int n = SSL_read(ssl, buf, sizeof(buf));
|
||||
if (n <= 0)
|
||||
throw coreutils::Exception("smtpsend: read failed", __FILE__, __LINE__, 502);
|
||||
recvBuffer.assign(buf, buf + n);
|
||||
recvPos = 0;
|
||||
}
|
||||
return recvBuffer[recvPos++];
|
||||
}
|
||||
|
||||
std::string __smtpsend::readLine() {
|
||||
std::string line;
|
||||
char c;
|
||||
for (;;) {
|
||||
c = readByte();
|
||||
if (c == '\n')
|
||||
break;
|
||||
if (c != '\r')
|
||||
line += c;
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
int __smtpsend::readReply(int expectedCode) {
|
||||
int code = 0;
|
||||
std::string line;
|
||||
for (;;) {
|
||||
line = readLine();
|
||||
if (line.size() < 4)
|
||||
throw coreutils::Exception("smtpsend: malformed reply: " + line, __FILE__, __LINE__, 502);
|
||||
code = atoi(line.substr(0, 3).c_str());
|
||||
if (line[3] == ' ')
|
||||
break;
|
||||
// else line[3] == '-': a continuation line, same code - keep reading.
|
||||
}
|
||||
if (code / 100 != expectedCode / 100)
|
||||
throw coreutils::Exception("smtpsend: unexpected reply " + std::to_string(code) + ": " + line, __FILE__, __LINE__, 502);
|
||||
return code;
|
||||
}
|
||||
|
||||
void __smtpsend::closeConnection() {
|
||||
if (ssl) { SSL_shutdown(ssl); SSL_free(ssl); ssl = nullptr; }
|
||||
if (fd >= 0) { ::close(fd); fd = -1; }
|
||||
if (ctx) { SSL_CTX_free(ctx); ctx = nullptr; }
|
||||
}
|
||||
|
||||
std::string __smtpsend::base64Encode(const std::string &s) {
|
||||
coreutils::Base64 base64;
|
||||
std::string copy = s;
|
||||
coreutils::ZString z(copy);
|
||||
return base64.encode(z).str();
|
||||
}
|
||||
|
||||
std::string __smtpsend::rfc2822Date() {
|
||||
time_t now = time(nullptr);
|
||||
struct tm tmResult{};
|
||||
gmtime_r(&now, &tmResult);
|
||||
char buf[64];
|
||||
strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S +0000", &tmResult);
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
// RFC 5322 3.6.4: Message-ID "SHOULD be present" - in practice
|
||||
// several real receivers (confirmed live: Gmail) now hard-reject
|
||||
// anything missing one ("550 5.7.1 Messages missing a valid
|
||||
// Message-ID header are not accepted") rather than just marking it
|
||||
// down, so this isn't optional in practice. Domain part is the
|
||||
// sender's own domain (everything after '@' in `from`), matching
|
||||
// RFC 5322's own recommendation that it be a name under the
|
||||
// generating system's control - falls back to the literal `from`
|
||||
// string in the (should-never-happen) case it has no '@' at all.
|
||||
std::string __smtpsend::generateMessageId(const std::string &from) {
|
||||
size_t at = from.find('@');
|
||||
std::string domainPart = (at == std::string::npos) ? from : from.substr(at + 1);
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
std::ostringstream idStream;
|
||||
idStream << ts.tv_sec << "." << std::setfill('0') << std::setw(9) << ts.tv_nsec
|
||||
<< "." << rand() << "@" << domainPart;
|
||||
return idStream.str();
|
||||
}
|
||||
|
||||
std::string __smtpsend::buildMessage(const std::string &from, const std::string &to,
|
||||
const std::string &subject, const std::string &html) {
|
||||
std::string msg;
|
||||
msg += "Date: " + rfc2822Date() + "\r\n";
|
||||
msg += "Message-ID: <" + generateMessageId(from) + ">\r\n";
|
||||
msg += "From: " + from + "\r\n";
|
||||
msg += "To: " + to + "\r\n";
|
||||
msg += "Subject: " + subject + "\r\n";
|
||||
msg += "MIME-Version: 1.0\r\n";
|
||||
msg += "Content-Type: text/html; charset=UTF-8\r\n";
|
||||
msg += "Content-Transfer-Encoding: 8bit\r\n";
|
||||
msg += "\r\n";
|
||||
// SMTP DATA's dot-stuffing rule: any body line starting with '.'
|
||||
// needs a second '.' prepended, or the server treats it as the
|
||||
// end-of-data marker prematurely and truncates the message.
|
||||
std::string stuffed;
|
||||
stuffed.reserve(html.size());
|
||||
bool atLineStart = true;
|
||||
for (size_t i = 0; i < html.size(); i++) {
|
||||
char c = html[i];
|
||||
if (atLineStart && c == '.')
|
||||
stuffed += '.';
|
||||
stuffed += c;
|
||||
atLineStart = (c == '\n');
|
||||
}
|
||||
msg += stuffed;
|
||||
return msg;
|
||||
}
|
||||
|
||||
__smtpsend::__smtpsend(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
std::string user = resolveKeyword("user").str();
|
||||
std::string password = resolveKeyword("password").str();
|
||||
std::string to = resolveKeyword("to").str();
|
||||
std::string subject = resolveKeyword("subject").str();
|
||||
std::string html = resolveKeyword("html").str();
|
||||
coreutils::MString configPath = resolveKeyword("config");
|
||||
|
||||
if (user.empty() || password.empty())
|
||||
throw coreutils::Exception("smtpsend: user/password must be specified.", __FILE__, __LINE__, 401);
|
||||
if (to.empty())
|
||||
throw coreutils::Exception("smtpsend: to address must be specified.", __FILE__, __LINE__, 400);
|
||||
|
||||
coreutils::JFile config(configPath);
|
||||
std::string host = config.getString("host");
|
||||
long port = (long)config.getNumber("smtpPort");
|
||||
if (port <= 0)
|
||||
port = 465;
|
||||
|
||||
struct addrinfo hints {};
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
struct addrinfo *result = nullptr;
|
||||
std::string portStr = std::to_string(port);
|
||||
if (getaddrinfo(host.c_str(), portStr.c_str(), &hints, &result) != 0 || !result)
|
||||
throw coreutils::Exception("smtpsend: could not resolve " + host, __FILE__, __LINE__, 502);
|
||||
|
||||
int newFd = -1;
|
||||
for (struct addrinfo *rp = result; rp != nullptr; rp = rp->ai_next) {
|
||||
newFd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
||||
if (newFd < 0)
|
||||
continue;
|
||||
if (::connect(newFd, rp->ai_addr, rp->ai_addrlen) == 0)
|
||||
break;
|
||||
::close(newFd);
|
||||
newFd = -1;
|
||||
}
|
||||
freeaddrinfo(result);
|
||||
if (newFd < 0)
|
||||
throw coreutils::Exception("smtpsend: could not connect to " + host, __FILE__, __LINE__, 502);
|
||||
|
||||
struct timeval timeout { 30, 0 };
|
||||
setsockopt(newFd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
|
||||
setsockopt(newFd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
|
||||
|
||||
SSL_CTX *newCtx = SSL_CTX_new(SSLv23_client_method());
|
||||
if (!newCtx) {
|
||||
::close(newFd);
|
||||
throw coreutils::Exception("smtpsend: SSL_CTX_new failed", __FILE__, __LINE__, 502);
|
||||
}
|
||||
SSL *newSsl = SSL_new(newCtx);
|
||||
SSL_set_fd(newSsl, newFd);
|
||||
if (SSL_connect(newSsl) != 1) {
|
||||
SSL_free(newSsl);
|
||||
SSL_CTX_free(newCtx);
|
||||
::close(newFd);
|
||||
throw coreutils::Exception("smtpsend: TLS handshake failed", __FILE__, __LINE__, 502);
|
||||
}
|
||||
|
||||
ctx = newCtx;
|
||||
ssl = newSsl;
|
||||
fd = newFd;
|
||||
|
||||
try {
|
||||
readReply(220);
|
||||
|
||||
sendLine("EHLO " + host);
|
||||
readReply(250);
|
||||
|
||||
sendLine("AUTH LOGIN");
|
||||
readReply(334);
|
||||
sendLine(base64Encode(user));
|
||||
readReply(334);
|
||||
sendLine(base64Encode(password));
|
||||
readReply(235);
|
||||
|
||||
sendLine("MAIL FROM:<" + user + ">");
|
||||
readReply(250);
|
||||
sendLine("RCPT TO:<" + to + ">");
|
||||
readReply(250);
|
||||
sendLine("DATA");
|
||||
readReply(354);
|
||||
|
||||
std::string message = buildMessage(user, to, subject, html);
|
||||
sendLine(message);
|
||||
sendLine(".");
|
||||
readReply(250);
|
||||
|
||||
sendLine("QUIT");
|
||||
readReply(221);
|
||||
} catch (...) {
|
||||
closeConnection();
|
||||
throw;
|
||||
}
|
||||
|
||||
closeConnection();
|
||||
|
||||
out = coreutils::MString(std::string("{\"ok\":true}"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#ifndef ____smtpsend_h__
|
||||
# define ____smtpsend_h__
|
||||
|
||||
# include "Tag.h"
|
||||
# include "ZString.h"
|
||||
# include "MString.h"
|
||||
# include <openssl/ssl.h>
|
||||
# include <string>
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <smtpsend config="./email.cfg" user="..." password="..."
|
||||
/// to="..." subject="..." html="...">
|
||||
///
|
||||
/// One-shot authenticated SMTP submission to BARANTMAIL's own
|
||||
/// implicit-TLS submission port (config key "smtpPort" - matches
|
||||
/// barantmail.cfg's smtpTLS.port, :465, the same implicit-TLS style
|
||||
/// as IMAP's :993 - no STARTTLS negotiation). Connects, TLS-
|
||||
/// handshakes, AUTH LOGIN with the SAME mailbox credentials already
|
||||
/// used by <imap> (so the message goes out authenticated as the
|
||||
/// actual connected mailbox, not the site's own transactional-mail
|
||||
/// identity - see barant.tag's separate <email> tag for that), then
|
||||
/// MAIL FROM/RCPT TO/DATAs a freshly-built RFC 5322 message
|
||||
/// (Date/From/To/Subject/MIME headers, HTML body), then QUITs. The
|
||||
/// authenticated user IS the From address - SMTP submission
|
||||
/// requires MAIL FROM to match the authenticated identity anyway, so
|
||||
/// there's no separate "from" keyword.
|
||||
///
|
||||
/// No connection pooling, unlike __imap - composing mail is rare
|
||||
/// enough that a fresh connect/auth/send/close per message is fine.
|
||||
///
|
||||
/// Throws coreutils::Exception (401 for a bad login, 502 for any
|
||||
/// other connect/protocol/rejected-recipient failure) on any
|
||||
/// failure - same convention as __imap.
|
||||
///
|
||||
class __smtpsend : public Tag {
|
||||
|
||||
public:
|
||||
__smtpsend(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
private:
|
||||
SSL_CTX *ctx = nullptr;
|
||||
SSL *ssl = nullptr;
|
||||
int fd = -1;
|
||||
std::string recvBuffer;
|
||||
size_t recvPos = 0;
|
||||
|
||||
void sendLine(const std::string &line);
|
||||
char readByte();
|
||||
std::string readLine();
|
||||
// Reads one (possibly multi-line, "250-text"/"250 text"
|
||||
// continuation-marked) SMTP reply and returns its 3-digit code;
|
||||
// throws if the code's first digit doesn't match expectedCode's.
|
||||
int readReply(int expectedCode);
|
||||
|
||||
void closeConnection();
|
||||
|
||||
static std::string base64Encode(const std::string &s);
|
||||
static std::string rfc2822Date();
|
||||
static std::string generateMessageId(const std::string &from);
|
||||
// Builds the full RFC 5322 message (headers + dot-stuffed body)
|
||||
// handed to SMTP's DATA command.
|
||||
static std::string buildMessage(const std::string &from, const std::string &to,
|
||||
const std::string &subject, const std::string &html);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -13,10 +13,34 @@ namespace jet {
|
||||
output = false;
|
||||
if(!hasContainer)
|
||||
throw coreutils::Exception("sql tag must have a container.");
|
||||
if(!global.sessionExists(keywords["sessionid"]))
|
||||
// resolveKeyword("sessionid") already returns the resolved VALUE
|
||||
// (e.g. "projman") - the query call below used to wrap that value
|
||||
// back into keywords[...] as if it were a MAP KEY, auto-vivifying
|
||||
// an empty string and silently running every <sql sessionid="X">
|
||||
// query (X != "") against the DEFAULT session instead of the one
|
||||
// actually named - same double-indirection bug already fixed in
|
||||
// __mysql.cpp's own constructor (see its own comment on this).
|
||||
// Resolved once into a local so both the existence check and the
|
||||
// query call agree on the real, resolved session id.
|
||||
coreutils::MString sessionId = resolveKeyword("sessionid");
|
||||
if(!global.sessionExists(sessionId))
|
||||
throw coreutils::Exception("sessionid does not exist.");
|
||||
processContainer(container);
|
||||
global.getSession(keywords[resolveKeyword("sessionid")])->query(out);
|
||||
__mysql *session = global.getSession(sessionId);
|
||||
// No <bind> inside: the query runs exactly as rendered, with no '?'
|
||||
// replacement at all, so existing queries containing a literal '?'
|
||||
// are unaffected. See docs/design-sql-bound-parameters.md.
|
||||
if(binds.empty()) {
|
||||
if(isCharsetChange(out.str()))
|
||||
throw coreutils::Exception("sql: changing the connection character set is not allowed.");
|
||||
session->query(out);
|
||||
return;
|
||||
}
|
||||
std::string bound = bindPlaceholders(out.str(), binds, session->noBackslashEscapes(),
|
||||
[session](const std::string &s) { return session->escapeString(s); });
|
||||
if(isCharsetChange(bound))
|
||||
throw coreutils::Exception("sql: changing the connection character set is not allowed.");
|
||||
session->query(coreutils::MString(bound));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
#define ____sql_h__
|
||||
|
||||
#include "Tag.h"
|
||||
#include "SqlBind.h"
|
||||
#include <vector>
|
||||
|
||||
namespace jet {
|
||||
|
||||
@@ -10,6 +12,13 @@ namespace jet {
|
||||
public:
|
||||
__sql(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
// Called by each <bind> inside this <sql> while its body renders.
|
||||
void addBind(BoundValue value) { binds.push_back(std::move(value)); }
|
||||
size_t bindCount() const { return binds.size(); }
|
||||
|
||||
private:
|
||||
std::vector<BoundValue> binds;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,45 @@
|
||||
|
||||
namespace jet {
|
||||
|
||||
__tag::__tag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, this, this) {
|
||||
__tag::__tag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
evaluate = false;
|
||||
output = false;
|
||||
if(!keywordDefined("name"))
|
||||
throw coreutils::Exception("tag must have a name.");
|
||||
if(!hasContainer)
|
||||
throw coreutils::Exception("tag requires a container to process.");
|
||||
global.tags[keywords["name"]] = container;
|
||||
|
||||
// A <tag> defined directly inside another custom tag's own
|
||||
// invocation (a __dotag instance's expansion) is scoped to that
|
||||
// invocation - only visible for the rest of it, not the whole
|
||||
// script. Control-flow tags like <if>/<for> that happen to sit in
|
||||
// between are transparent (walked past, not boundaries themselves).
|
||||
// Reaching parent==NULL (true top level) falls back to the original
|
||||
// single flat global.tags map, unchanged from before. This relies
|
||||
// on `parent` here actually being the real enclosing tag - the base
|
||||
// Tag(...) call above used to pass (this, this) instead of the
|
||||
// parent/local this constructor actually received, which would have
|
||||
// made this walk loop on itself forever; fixed as part of adding
|
||||
// this scoping (parent/local weren't needed anywhere else in this
|
||||
// class - <tag>'s own container is never evaluated at definition
|
||||
// time, evaluate=false above, so nothing depended on the old
|
||||
// self-referential values).
|
||||
Tag *scope = parent;
|
||||
while(scope && !scope->isCustomTagBoundary)
|
||||
scope = scope->parent;
|
||||
// Custom tag NAMES are matched case-insensitively at invocation
|
||||
// (findTagDefinition normalizes its own lookup key the same way),
|
||||
// matching the precedent already set for built-in tag names
|
||||
// (ifTagName) and attribute names - real 1.4 content declares and
|
||||
// invokes a custom tag in different case at different sites (e.g.
|
||||
// SESSIONCTL.tag's own <TAG NAME='TEMPLATE'> definition vs
|
||||
// mainpagetemplate.temp's <template>...</template> invocation of
|
||||
// it). Registering under the lowercase key here is what makes that
|
||||
// match.
|
||||
coreutils::MString tagName = coreutils::MString(keywords["name"]).toLower();
|
||||
if(scope)
|
||||
scope->localTags[tagName] = container;
|
||||
else
|
||||
global.tags[tagName] = container;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "__trytag.h"
|
||||
#include "Exception.h"
|
||||
#include <exception>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__trytag::__trytag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local)
|
||||
: Tag(in, parentOut, global, parent, this, "catch") {
|
||||
|
||||
coreutils::MString errorText;
|
||||
bool failed = false;
|
||||
|
||||
try {
|
||||
processContainer(container);
|
||||
} catch(coreutils::Exception &e) {
|
||||
errorText = e.text;
|
||||
failed = true;
|
||||
} catch(std::exception &e) {
|
||||
errorText = e.what();
|
||||
failed = true;
|
||||
} catch(...) {
|
||||
errorText = "unknown error";
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if(failed) {
|
||||
// Discard whatever the failed attempt had already written before
|
||||
// it threw - out is this tag's own accumulating output buffer
|
||||
// (processContainer(container) above wrote into it directly), so
|
||||
// without this a caught mid-render failure would leave partial
|
||||
// try-block output mixed in ahead of the catch block's own.
|
||||
out = "";
|
||||
// <try name="err"> or <catch name="err"> (the usual form).
|
||||
if(keywordDefined("name"))
|
||||
storeVariable(resolveKeyword("name"), errorText,
|
||||
keywordDefined("scope") ? resolveKeyword("scope") : "global");
|
||||
else if(splitKeywords.count("name"))
|
||||
storeVariable(splitKeywords["name"], errorText,
|
||||
splitKeywords.count("scope") ? coreutils::ZString(splitKeywords["scope"]) : coreutils::ZString("global"));
|
||||
if(hasContainer2)
|
||||
processContainer(container2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef ____trytag_h__
|
||||
#define ____trytag_h__
|
||||
|
||||
#include "Tag.h"
|
||||
#include "ZString.h"
|
||||
#include "MString.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
///
|
||||
/// <try>...container...<catch>...container2...</catch></try>
|
||||
///
|
||||
/// Runs its own container the same as any other tag; if that raises an
|
||||
/// error that would otherwise propagate up and halt the whole script -
|
||||
/// a coreutils::Exception (what every other tag actually throws), any
|
||||
/// other std::exception (e.g. the std::filesystem::filesystem_error
|
||||
/// <whiledir> can raise), or anything else - the <catch> container (if
|
||||
/// present) runs instead, with any partial output the failed attempt
|
||||
/// had already written discarded first so the result is cleanly either
|
||||
/// the try's output or the catch's, never a mix of both.
|
||||
///
|
||||
/// Optional keywords, both meaningful only on catch: name (a variable
|
||||
/// to receive the caught error's message text) and scope (global by
|
||||
/// default, or local/parent - same convention as <for>'s own name/scope
|
||||
/// pair).
|
||||
///
|
||||
/// Named __trytag rather than __try: <ios> transitively defines a
|
||||
/// preprocessor macro "#define __try try" (an SEH-compatibility shim
|
||||
/// pulled in on this toolchain) that silently rewrites the identifier
|
||||
/// __try to the literal keyword try wherever it appears, breaking
|
||||
/// compilation - confirmed via `g++ -E -dM` before picking this name,
|
||||
/// not guessed. The JET tag name itself is still plain <try> - this
|
||||
/// only affects the internal C++ class name, matched by ifTagName(in,
|
||||
/// "try") in Tag.cpp regardless of what the class is called.
|
||||
///
|
||||
|
||||
class __trytag : public Tag {
|
||||
|
||||
public:
|
||||
__trytag(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -21,7 +21,7 @@ namespace jet {
|
||||
if(!keywordDefined("type"))
|
||||
throw coreutils::Exception("type expected if value1 and value2 specified.");
|
||||
|
||||
int rc = keywords[resolveKeyword("value1")].compare(keywords[resolveKeyword("value2")]);
|
||||
int rc = resolveKeyword("value1").compare(resolveKeyword("value2"));
|
||||
if(((keywords[resolveKeyword("type")] == "eq") && (rc == 0)) ||
|
||||
((keywords[resolveKeyword("type")] == "ne") && (rc != 0)) ||
|
||||
((keywords[resolveKeyword("type")] == "lt") && (rc == -1)) ||
|
||||
@@ -50,7 +50,7 @@ namespace jet {
|
||||
booleanResult = Operand(keywords["expr"], *this).boolean;
|
||||
} else {
|
||||
booleanResult = false;
|
||||
int rc = keywords[resolveKeyword("value1")].compare(keywords[resolveKeyword("value2")]);
|
||||
int rc = resolveKeyword("value1").compare(resolveKeyword("value2"));
|
||||
if(((keywords[resolveKeyword("type")] == "eq") && (rc == 0)) ||
|
||||
((keywords[resolveKeyword("type")] == "ne") && (rc != 0)) ||
|
||||
((keywords[resolveKeyword("type")] == "lt") && (rc == -1)) ||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace jet {
|
||||
if(!keywordDefined("type"))
|
||||
throw coreutils::Exception("type expected if value1 and value2 specified.");
|
||||
|
||||
int rc = keywords[resolveKeyword("value1")].compare(keywords[resolveKeyword("value2")]);
|
||||
int rc = resolveKeyword("value1").compare(resolveKeyword("value2"));
|
||||
if(((keywords[resolveKeyword("type")] == "eq") && (rc == 0)) ||
|
||||
((keywords[resolveKeyword("type")] == "ne") && (rc != 0)) ||
|
||||
((keywords[resolveKeyword("type")] == "lt") && (rc == -1)) ||
|
||||
@@ -50,7 +50,7 @@ namespace jet {
|
||||
booleanResult = Operand(keywords["expr"], *this).boolean;
|
||||
} else {
|
||||
booleanResult = false;
|
||||
int rc = keywords[resolveKeyword("value1")].compare(keywords[resolveKeyword("value2")]);
|
||||
int rc = resolveKeyword("value1").compare(resolveKeyword("value2"));
|
||||
if(((keywords[resolveKeyword("type")] == "eq") && (rc == 0)) ||
|
||||
((keywords[resolveKeyword("type")] == "ne") && (rc != 0)) ||
|
||||
((keywords[resolveKeyword("type")] == "lt") && (rc == -1)) ||
|
||||
|
||||
@@ -9,34 +9,99 @@
|
||||
namespace jet {
|
||||
|
||||
__whiledir::__whiledir(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, this) {
|
||||
if(!keywordDefined("path"))
|
||||
// Real 1.4 content (barantmusic.page/davidarant.page's own
|
||||
// bae1996.section) writes <whiledir dir="..." name="filename">,
|
||||
// not <whiledir path="..." filename="...">. Accept "dir" as an
|
||||
// alias for "path" and "name" as an alias for "filename" so that
|
||||
// content runs unmodified, matching the same "accept either"
|
||||
// precedent already used for <database name=>/<mysql database=>.
|
||||
// Resolved once into real local VALUES (not a dynamically-chosen
|
||||
// keyword NAME threaded through repeated keywordDefined()/
|
||||
// resolveKeyword() calls) - an earlier version of this fix passed
|
||||
// a ZString holding just the chosen attribute name around and hit
|
||||
// real, unexplained corruption (a whiledir on a real, correctly
|
||||
// specified directory resolved to a garbage nonsense path instead).
|
||||
// This form fixed it in isolation (a standalone whiledir_test.jet
|
||||
// against this exact directory/attributes works perfectly) but the
|
||||
// SAME garbage path still recurs when this exact content
|
||||
// (bae1996.section) is reached through real content's actual deep
|
||||
// <eval>/<dotag>/<include> nesting (40+ stack frames by that
|
||||
// point) - genuinely not yet root-caused; flagged in project
|
||||
// memory as still open. The try/catch below at least converts
|
||||
// whatever throws there into the same graceful, catchable error
|
||||
// page every other tag failure already gets, instead of a raw
|
||||
// std::exception unwinding past everything and dropping the
|
||||
// connection with no HTTP response at all.
|
||||
coreutils::MString dirPath;
|
||||
if(keywordDefined("path"))
|
||||
dirPath = resolveKeyword("path");
|
||||
else if(keywordDefined("dir"))
|
||||
dirPath = resolveKeyword("dir");
|
||||
else
|
||||
throw coreutils::Exception("whiledir tag must specify a path.");
|
||||
if(keywordDefined("sort") && (resolveKeyword("sort") == "true")) {
|
||||
std::vector<std::filesystem::directory_entry> entries;
|
||||
for(auto const &entry : std::filesystem::directory_iterator(resolveKeyword("path").str()))
|
||||
entries.push_back(entry);
|
||||
std::sort(entries.begin(), entries.end(), [](const auto &a, const auto &b) { return a.path() < b.path(); });
|
||||
for(const auto &entry : entries) {
|
||||
if(keywordDefined("fullpath"))
|
||||
global.variables[resolveKeyword("fullpath")] = entry.path();
|
||||
if(keywordDefined("filename"))
|
||||
global.variables[resolveKeyword("filename")] = entry.path().filename();
|
||||
if(keywordDefined("filenamenoextension"))
|
||||
global.variables[resolveKeyword("filenamenoextension")] = entry.path().stem();
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
}
|
||||
} else {
|
||||
for(auto const &entry : std::filesystem::directory_iterator(variables[resolveKeyword("path")].str())) {
|
||||
if(keywordDefined("fullpath"))
|
||||
global.variables[resolveKeyword("fullpath")] = entry.path();
|
||||
if(keywordDefined("filename"))
|
||||
global.variables[resolveKeyword("filename")] = entry.path().filename();
|
||||
if(keywordDefined("filenamenoextension"))
|
||||
global.variables[resolveKeyword("filenamenoextension")] = entry.path().stem();
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
|
||||
// Every one of these attributes - which output variable name to
|
||||
// assign into for a given field, and whether that field was even
|
||||
// requested - is a static property of this <whiledir> invocation,
|
||||
// fixed at construction, never changing across its own loop. The
|
||||
// per-iteration body used to call keywordDefined()+resolveKeyword()
|
||||
// (2 map lookups each) for fullpath/filename/filenamenoextension
|
||||
// on every single directory entry - resolved once here instead,
|
||||
// same reasoning as __whilerow.cpp's session-pointer hoist.
|
||||
coreutils::MString filenameVarName;
|
||||
bool haveFilenameVar = false;
|
||||
if(keywordDefined("filename")) {
|
||||
filenameVarName = resolveKeyword("filename");
|
||||
haveFilenameVar = true;
|
||||
} else if(keywordDefined("name")) {
|
||||
filenameVarName = resolveKeyword("name");
|
||||
haveFilenameVar = true;
|
||||
}
|
||||
|
||||
coreutils::MString fullpathVarName;
|
||||
bool haveFullpathVar = keywordDefined("fullpath");
|
||||
if(haveFullpathVar)
|
||||
fullpathVarName = resolveKeyword("fullpath");
|
||||
|
||||
coreutils::MString noExtVarName;
|
||||
bool haveNoExtVar = keywordDefined("filenamenoextension");
|
||||
if(haveNoExtVar)
|
||||
noExtVarName = resolveKeyword("filenamenoextension");
|
||||
|
||||
bool sorted = keywordDefined("sort") && (resolveKeyword("sort") == "true");
|
||||
|
||||
try {
|
||||
if(sorted) {
|
||||
std::vector<std::filesystem::directory_entry> entries;
|
||||
for(auto const &entry : std::filesystem::directory_iterator(dirPath.str()))
|
||||
entries.push_back(entry);
|
||||
std::sort(entries.begin(), entries.end(), [](const auto &a, const auto &b) { return a.path() < b.path(); });
|
||||
for(const auto &entry : entries) {
|
||||
if(haveFullpathVar)
|
||||
global.variables[fullpathVarName] = entry.path();
|
||||
if(haveFilenameVar)
|
||||
global.variables[filenameVarName] = entry.path().filename();
|
||||
if(haveNoExtVar)
|
||||
global.variables[noExtVarName] = entry.path().stem();
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
}
|
||||
} else {
|
||||
for(auto const &entry : std::filesystem::directory_iterator(dirPath.str())) {
|
||||
if(haveFullpathVar)
|
||||
global.variables[fullpathVarName] = entry.path();
|
||||
if(haveFilenameVar)
|
||||
global.variables[filenameVarName] = entry.path().filename();
|
||||
if(haveNoExtVar)
|
||||
global.variables[noExtVarName] = entry.path().stem();
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
}
|
||||
}
|
||||
} catch(std::exception &e) {
|
||||
coreutils::MString msg("whiledir failed: ");
|
||||
msg << e.what();
|
||||
throw coreutils::Exception(msg.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,12 +7,31 @@ namespace jet {
|
||||
|
||||
__whilerow::__whilerow(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
|
||||
|
||||
int count = keywords["count"].asInteger();
|
||||
// A bare <whilerow> (no count= attribute at all - the overwhelming
|
||||
// majority of real usage: modular1_patches.page, account.page,
|
||||
// task.page, project.page, editinvoice.page, musicianhome.page,
|
||||
// invoice.method, modular1_1_preset_admin.page) used to default
|
||||
// count to 0 - keywords["count"] auto-vivifies an empty string for
|
||||
// a missing attribute, and "".asInteger() is 0 - which made the
|
||||
// loop's own (count != 0) condition false on the very first check,
|
||||
// before hasRow() was ever even consulted. Every one of those
|
||||
// pages' row-based content silently rendered nothing, for every
|
||||
// request, this entire session - never caught because nothing
|
||||
// that exercised a bare <whilerow> with real row data also had its
|
||||
// actual rendered output inspected until now. count= is meant as
|
||||
// an OPTIONAL cap ("show at most N rows"); absent, it must mean
|
||||
// unlimited, not zero - -1 as a sentinel keeps working with the
|
||||
// existing (count != 0) loop test forever (decrementing through
|
||||
// negative numbers never hits 0), letting hasRow() alone decide
|
||||
// when the loop ends, exactly as bare usage always intended.
|
||||
int count = keywordDefined("count") ? keywords["count"].asInteger() : -1;
|
||||
|
||||
while ((count != 0) && global.getSession(keywords["sessionid"])->hasRow()) {
|
||||
__mysql *session = global.getSession(resolveKeyword("sessionid"));
|
||||
|
||||
while((count != 0) && session->hasRow()) {
|
||||
processContainer(container);
|
||||
container.reset();
|
||||
global.getSession(keywords["sessionid"])->nextRow();
|
||||
session->nextRow();
|
||||
--count;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,19 +24,49 @@ namespace jet {
|
||||
throw coreutils::Exception("write tag must have a value, expr or a container.");
|
||||
if(!keywordDefined("mode"))
|
||||
throw coreutils::Exception("write tag must have a mode keyword.");
|
||||
if(keywords[resolveKeyword("mode")] == "append")
|
||||
// resolveKeyword("mode") already returns the resolved VALUE (e.g.
|
||||
// "overwrite") - re-indexing keywords[...] with that value treats
|
||||
// it as if it were a MAP KEY instead (auto-vivifying an empty
|
||||
// string, since no keyword is literally named "overwrite"/
|
||||
// "append"), so this comparison was false for every real input
|
||||
// and <write> threw "mode keyword must be..." unconditionally.
|
||||
// Same double-indirection bug already fixed elsewhere in this
|
||||
// codebase (__mysql.cpp's own constructor, __sql.cpp's sessionid
|
||||
// handling) - confirmed via a real repro building the jet-2.0
|
||||
// htmleditor port's file-based storage.
|
||||
coreutils::MString modeValue = resolveKeyword("mode");
|
||||
if(modeValue == "append")
|
||||
mode = O_APPEND;
|
||||
else if(keywords[resolveKeyword("mode")] == "overwrite")
|
||||
else if(modeValue == "overwrite")
|
||||
mode = O_TRUNC;
|
||||
else
|
||||
throw coreutils::Exception("mode keyword must be 'overwrite' or 'append'.");
|
||||
int fd = open(keywords[resolveKeyword("file")].c_str(), mode, 0644); // TODO: Need to add O_CREAT and AUTH flags.
|
||||
// mode alone (O_APPEND or O_TRUNC) has no access-mode bits at
|
||||
// all - open()'s access mode defaults to O_RDONLY (0) unless
|
||||
// O_WRONLY/O_RDWR is explicitly OR'd in, so the write() call below
|
||||
// was failing on every real invocation (EBADF - can't write a
|
||||
// read-only fd), and without O_CREAT this could never create a
|
||||
// NEW file either, only (theoretically) write an existing one.
|
||||
// Confirmed via a real repro: <write file="..." mode="overwrite">
|
||||
// silently produced a 0-byte or missing file every time.
|
||||
// Same double-indirection bug as "mode" above.
|
||||
int fd = open(resolveKeyword("file").c_str(), mode | O_WRONLY | O_CREAT, 0644); // TODO: Need to add AUTH flags.
|
||||
if(hasContainer && !evaluate)
|
||||
len = write(fd, container.getData(), container.getLength());
|
||||
else if(hasContainer && evaluate)
|
||||
len = write(fd, out.getData(), out.getLength());
|
||||
else if(!hasContainer && keywordDefined("value"))
|
||||
len = write(fd, variables[resolveKeyword("value")].getData(), keywords[resolveKeyword("value")].getLength());
|
||||
else if(!hasContainer && keywordDefined("value")) {
|
||||
// Same double-indirection bug as "mode"/"file" above:
|
||||
// variables[resolveKeyword("value")] used the resolved VALUE
|
||||
// itself as a lookup key into global.variables (a DIFFERENT map
|
||||
// entirely), not the literal value to write - looking up a
|
||||
// variable literally named e.g. "hello world" auto-vivifies an
|
||||
// empty entry, so this wrote 0 bytes for every real invocation.
|
||||
// Confirmed via a real repro: <write value="hello world"
|
||||
// mode="overwrite"> produced a genuinely empty file.
|
||||
coreutils::MString writeValue = resolveKeyword("value");
|
||||
len = write(fd, writeValue.getData(), writeValue.getLength());
|
||||
}
|
||||
else if(!hasContainer && keywordDefined("expr"))
|
||||
len = write(fd, keywords["expr"].getData(), keywords["expr"].getLength());
|
||||
close(fd);
|
||||
|
||||
@@ -18,7 +18,7 @@ done
|
||||
|
||||
wait
|
||||
echo -n "Building executable jet-2.0..."
|
||||
g++ -g -o jet-2.0 $list -std=c++23 -L../CoreUtils -lCoreUtils -lmysqlclient -lcrypto
|
||||
g++ -g -o jet-2.0 $list -std=c++23 -L../CoreUtils -lCoreUtils -lmysqlclient -lssl -lcrypto
|
||||
if [ $? = '0' ]
|
||||
then
|
||||
echo "OK"
|
||||
|
||||
@@ -0,0 +1,733 @@
|
||||
\documentclass{book}
|
||||
\usepackage{fontspec}
|
||||
\setmainfont{Roboto}
|
||||
|
||||
\title{JET Extension Tags}
|
||||
\author{Bradford Matthew Arant Sr.}
|
||||
\date{\today}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\chapter{Introduction}
|
||||
|
||||
JET will pass through the untagged areas to the output without any
|
||||
modifications. Data contained within the tags may modify their
|
||||
containers before placing any output. The space taken by the tag
|
||||
itself is not passed to the output and will not appear in the output.
|
||||
|
||||
Skip Blank Lines options on containers will skip passing any blank
|
||||
lines or line containing only whitespace to the output.
|
||||
|
||||
\section{Use Cases}
|
||||
|
||||
\subsection{World Wide Web Site}
|
||||
|
||||
\subsection{API Handling}
|
||||
|
||||
\subsection{Asterisk Dial Plan Generator Tool}
|
||||
|
||||
\chapter{Tags and Attributes}
|
||||
|
||||
XML style tagging is used to insert functions and other behaviors into
|
||||
the script. As the document contents are output a tag may be inserted
|
||||
to perform the desired function and affect the output.
|
||||
|
||||
Tag attributes are used to pass parameters into the operations and
|
||||
functionality for each tag.
|
||||
|
||||
Outputting a database from mysql may be performed using the <mysql\> tag
|
||||
in combination with the <ifrow\>, <whilerow\> and <sql\> tags.
|
||||
|
||||
\chapter{User Defined Tags and Tag Libraries}
|
||||
|
||||
You can define your own tag definitions and use them within your JET
|
||||
scripts.
|
||||
|
||||
Keywords are not defined as part of the tag definition and any
|
||||
attribute added to the implementation of the tag is passed into the
|
||||
tag process as a local variable for that container.
|
||||
|
||||
Tag definitions can also be defined as scoped or unscoped, as follows:
|
||||
|
||||
scoped - local variables using the \#[n] format can be scoped to just
|
||||
your tag contents. Access to local variables where your tag is being
|
||||
used must use the 'parent' scope option to retrieve variables from the
|
||||
parent.
|
||||
|
||||
unscoped - local variables are shared with the parent tag environment
|
||||
and are not unique to your tag definition.
|
||||
|
||||
A <container /> tag can be inserted into the container and will take
|
||||
the contents of the container at runtime and insert it into the output
|
||||
when processing the user defined tag definition. The container tag of
|
||||
the the <container /> is processed before the container containing the
|
||||
<container /> so that local variabls can be set and processed that
|
||||
will affect the tags overall output.
|
||||
|
||||
Tags are many times nested with tags running within the container of a
|
||||
higher tag.
|
||||
|
||||
|
||||
|
||||
\chapter{Variables and Variable Types}
|
||||
|
||||
Variables are used to contain dynamic content values and can be
|
||||
sourced from several locations and limited in scope depending on use.
|
||||
Some variable types can be set to reflect script state or are read
|
||||
only from other outside sources of data.
|
||||
|
||||
Jet tags can be either scoped or unscoped.
|
||||
|
||||
The following is a list of
|
||||
variable types and a brief description of their source:
|
||||
|
||||
\begin{itemize}
|
||||
|
||||
\item Global - values can be initialized using the set tag and
|
||||
specifying the scope of global.
|
||||
|
||||
\item Local -
|
||||
|
||||
\item Keyword - within a tag's container we may access the keyword
|
||||
values specified on the containing tag.
|
||||
|
||||
\item Session - values stored in the session file with the set tag and
|
||||
a scope of session. They persist across requests from the same browser.
|
||||
|
||||
\item Environment -
|
||||
|
||||
\item CGI Variables -
|
||||
|
||||
\end{itemize}
|
||||
|
||||
\section{Global Variables}
|
||||
|
||||
Global variables are available to all logic once the values have been
|
||||
set.
|
||||
|
||||
Global variables are accessed throughout the procedure with the
|
||||
\$[name] syntax.
|
||||
|
||||
Global is the default if the scope is
|
||||
not specified for any function that writes to a variable.
|
||||
|
||||
\section{Local Variables}
|
||||
|
||||
Local variables are established using the set tag and specifying a
|
||||
scope of local. Local variables are typically only available within
|
||||
the container where they are defined. Some containers may not be
|
||||
capable of storing local variables (i.e. set tag) and are inheriting
|
||||
the local scope from their parent tag.
|
||||
|
||||
\section{Session Variables}
|
||||
|
||||
Session variables are stored in the session file for the current
|
||||
session and remain available to later requests from the same browser.
|
||||
Session control must be enabled (see Session Control).
|
||||
|
||||
A session variable is written with the set tag and a scope of
|
||||
session:
|
||||
|
||||
\begin{verbatim}
|
||||
<set name="_login_id" value="$[login_id]" scope="session">
|
||||
\end{verbatim}
|
||||
|
||||
The name can be any variable name. It does not need an @ prefix.
|
||||
Session variables are read with the \$[@name] syntax, for example
|
||||
\$[@\_login\_id].
|
||||
|
||||
Setting a session variable does not also set a global variable of
|
||||
the same name. When the same request needs to read the value as
|
||||
\$[name], set it with both scopes:
|
||||
|
||||
\begin{verbatim}
|
||||
<set name="_login_id" value="$[login_id]">
|
||||
<set name="_login_id" value="$[login_id]" scope="session">
|
||||
\end{verbatim}
|
||||
|
||||
\section{Keyword Variables}
|
||||
|
||||
Keyword variables are set when they are specified on a containing tag.
|
||||
Within the container you can access the variable using the syntax
|
||||
\$[\%name].
|
||||
|
||||
The variable retrieved is not processed for variable resolution.
|
||||
|
||||
\section{Environment Variables}
|
||||
|
||||
Environment variables are values existing in the exported list of value/pairs as provided by the operating system process. Apache, NGINX as well as other HTML server platforms provide environment variables to describe the requests being handed in.
|
||||
|
||||
\section{CGI Variables}
|
||||
|
||||
When operating Jet in CGI mode you have access to the form data
|
||||
submitted by the remote client (usually a browser or curl request)
|
||||
using the POST method.
|
||||
|
||||
\sectionmark{Expressions}
|
||||
|
||||
Expressions are used to perform complicated calculations (arithmetic), perform
|
||||
comparisons between values (boolean), manipulate strings (string) or
|
||||
perform operations on dates (date).
|
||||
|
||||
\chapter{Expressions}
|
||||
|
||||
\section{Operators}
|
||||
|
||||
Operators are used to perform arithmetic or boolean operations on
|
||||
arguments to derive a particular result. There are two types of
|
||||
operators, as follows:
|
||||
|
||||
\begin{itemize}
|
||||
|
||||
\item Arithmetic -
|
||||
|
||||
\item Boolean -
|
||||
|
||||
\end{itemize}
|
||||
|
||||
\subsection{Arithmetic Operators}
|
||||
|
||||
\subsection{Boolean Operators}
|
||||
|
||||
\section{Function Reference}
|
||||
|
||||
\section{Date Functions}
|
||||
|
||||
\subsection{datediff}
|
||||
|
||||
\subsection{unixtime}
|
||||
|
||||
\section{Math Functions}
|
||||
|
||||
\subsection{abs}
|
||||
|
||||
Returns the absolute value of the given parameter.
|
||||
|
||||
\subsection{acos}
|
||||
|
||||
Returns to arc cosine of the given parameter.
|
||||
|
||||
\subsection{asin}
|
||||
|
||||
\subsection{atan}
|
||||
|
||||
\subsection{cos}
|
||||
|
||||
\subsection{floor}
|
||||
|
||||
\subsection{ceil}
|
||||
|
||||
\subsection{max}
|
||||
|
||||
Returns the greatest value item from a list of comma seperated values in a
|
||||
list.
|
||||
|
||||
\subsection{min}
|
||||
|
||||
Returns the least value item from a list of comma seperated values in
|
||||
a list.
|
||||
|
||||
\subsection{pow}
|
||||
|
||||
\subsection{random}
|
||||
|
||||
Use the random function to return a random number between 0 and 1.
|
||||
|
||||
\subsection{sin}
|
||||
|
||||
\section{String Functions}
|
||||
|
||||
String functions are provided to accelerate the building and parsing of
|
||||
strings passed into the expression. Numbers can be treated as a string or
|
||||
a number depending on the function called and the data state of the values
|
||||
being manipulated.
|
||||
|
||||
\subsection{concat}
|
||||
|
||||
The concat function is used to assemble a string by concatenating one or
|
||||
more values to formulate the resulting string.
|
||||
|
||||
|
||||
|
||||
\subsection{integer}
|
||||
|
||||
\subsection{left}
|
||||
|
||||
Use the left function to return the number of characters specified in
|
||||
the second parameter from the parameter passed as the first parameter.
|
||||
|
||||
If the number of characters to return is greater than the length of
|
||||
the first parameter then the entire parameter is returned.
|
||||
|
||||
\subsection{ltrim}
|
||||
|
||||
Use the ltrim function to remove the leading blanks (spaces, tabs and
|
||||
newlines) from a value. Trailing blanks are kept.
|
||||
|
||||
\begin{verbatim}
|
||||
ltrim(' abc ') returns 'abc '
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{reverse}
|
||||
|
||||
\subsection{right}
|
||||
|
||||
\subsection{round}
|
||||
|
||||
Use the round function to round a numeric value to the specified
|
||||
number of digits after the decimal point.
|
||||
|
||||
\subsection{rtrim}
|
||||
|
||||
Use the rtrim function to remove the trailing blanks (spaces, tabs and
|
||||
newlines) from a value. Leading blanks are kept.
|
||||
|
||||
\begin{verbatim}
|
||||
rtrim(' abc ') returns ' abc'
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{substring}
|
||||
|
||||
Use the substring operation to extract a portion of a string and return
|
||||
the value as a string.
|
||||
|
||||
\subsection{tolower}
|
||||
|
||||
\subsection{toupper}
|
||||
|
||||
\subsection{trim}
|
||||
|
||||
Use the trim function to remove the blanks (spaces, tabs and newlines)
|
||||
from both ends of a value. See also ltrim and rtrim.
|
||||
|
||||
\begin{verbatim}
|
||||
trim(' abc ') returns 'abc'
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{expr}
|
||||
|
||||
Use the expr function to parse the string contents contained in the expr string.
|
||||
|
||||
\chapter{Common Gateway Interface Features}
|
||||
|
||||
JET extension tags provides options for enabling the processing of
|
||||
data using the Common Gateway Interface (CGI) specification used by
|
||||
Apache and NGINX as well as other HTTP server applications. This makes
|
||||
JET a powerful tool for creating web interfaces and API handler
|
||||
environments for various javascript frameworks as well as just native
|
||||
HTML style interaction.
|
||||
|
||||
To enable the CGI features within a requested document you can specify
|
||||
the cgi="true" attribute on a <jet> tag containing the document or
|
||||
<jet /> tag contained within the document.
|
||||
|
||||
When you enable the CGI interface the script will look for specific
|
||||
environment variables used to retrieve the input data from the browser
|
||||
interface and automatically provide these values to the JET scripting
|
||||
using the variables interface. There are currently three supported
|
||||
data formats or content types through this interface. These content
|
||||
types are:
|
||||
|
||||
formdata/urlencoded
|
||||
mutipart/formdata
|
||||
text/json
|
||||
|
||||
\section{Session Control}
|
||||
|
||||
Common use of the CGI is requiring the transaction based interaction
|
||||
of a web browser to maintain a state between interactions. JET 2.0
|
||||
provides a built in mechanism to assist in managing a session concept.
|
||||
This approach uses a single session cookie to identify the session to
|
||||
the back end services.
|
||||
|
||||
By specifying a seesiondir keyword on the <jet> tag you enable the
|
||||
session control functionality. Upon the delivery of a request that
|
||||
does not contain a session 'token' a session token will be generated
|
||||
for the request and a cookie will be returned in the reponse
|
||||
containing the session token. Additionally, a session file is placed
|
||||
into the directory named after the token. Captured session data will
|
||||
become available to future requests coming into the server and made
|
||||
available through the variable formats for the session.
|
||||
|
||||
Under APIServer, session control is enabled for a site by its
|
||||
sessionDir setting in the server configuration instead of the <jet>
|
||||
tag.
|
||||
|
||||
Use the <set> tag with scope="session" to store a value in the
|
||||
session, and \$[@name] to read it back (see Session Variables).
|
||||
|
||||
The session tags in SESSIONCTL.tag are deprecated for session
|
||||
management. Its setenv tag has been removed, and the startsession and
|
||||
endsession tags are no longer provided. Use scope="session" instead.
|
||||
|
||||
|
||||
|
||||
\chapter{Tag Reference}
|
||||
|
||||
This chapter will cover all the tags and parameters required to
|
||||
perform the operations that JET provides.
|
||||
|
||||
A special character sequence is used to exclude a section from tag and
|
||||
variable parsing. This sequence is |> this is not parsed or resolved
|
||||
<|. This takes affect through all levels and depths of tag processing
|
||||
and is different from the <exclude /> tag as exclude may be further
|
||||
parsed if output is again evaluated.
|
||||
|
||||
\section{bind}
|
||||
|
||||
Use the bind tag inside an sql tag to supply the value for a ?
|
||||
placeholder in the statement. Each bind fills the next ? in order. The
|
||||
value is escaped or checked before it reaches the server, so whatever
|
||||
it contains can never change the meaning of the statement. Use bind for
|
||||
every value that comes from a request, a cookie or a session instead of
|
||||
writing \$[name] into the statement text.
|
||||
|
||||
The bind tag has no closing tag and produces no output. It must be
|
||||
inside an sql tag, although it may be inside other tags (if, for and so
|
||||
on) within that sql tag.
|
||||
|
||||
\begin{verbatim}
|
||||
<sql>select id, name from users where email=? and status=?
|
||||
<bind value="$[email]">
|
||||
<bind value="ACTIVE">
|
||||
</sql>
|
||||
\end{verbatim}
|
||||
|
||||
The attributes are:
|
||||
|
||||
value - the value to bind. Required. Any expression or variable
|
||||
reference may be used here.
|
||||
|
||||
type - how the value is checked and sent. The values are:
|
||||
|
||||
\begin{itemize}
|
||||
\item string - the default. Quoted and escaped.
|
||||
\item int - a whole number of up to 19 digits, optionally negative.
|
||||
Sent without quotes.
|
||||
\item decimal - a number with an optional fraction, for example
|
||||
-12.50. Sent without quotes.
|
||||
\item bool - 1, true, yes, 0, false or no (any case). Sent as 1 or 0.
|
||||
\item date - YYYY-MM-DD.
|
||||
\item datetime - YYYY-MM-DD HH:MM or YYYY-MM-DD HH:MM:SS.
|
||||
\item ident - a column or table name, or a sort direction, for the
|
||||
places SQL cannot take a value (ORDER BY and so on). Requires the allow
|
||||
attribute. Names are sent in backticks; ASC and DESC are sent as they
|
||||
are.
|
||||
\end{itemize}
|
||||
|
||||
null - set to empty to send SQL NULL when the value is empty. Without
|
||||
it an empty value is sent as an empty string (and is an error for int,
|
||||
decimal, bool, date and datetime).
|
||||
|
||||
allow - for type="ident" only. A comma separated list of the values
|
||||
that are permitted. Any other value is an error.
|
||||
|
||||
\begin{verbatim}
|
||||
<sql>select * from products order by ? ?
|
||||
<bind value="$[sort]" type="ident" allow="name,price,created">
|
||||
<bind value="$[dir]" type="ident" allow="ASC,DESC">
|
||||
</sql>
|
||||
\end{verbatim}
|
||||
|
||||
A ? inside a quoted string, a backtick name or a comment in the
|
||||
statement is not a placeholder. An sql tag that contains no bind tags
|
||||
is run exactly as written, so a ? in it is left alone.
|
||||
|
||||
These are errors, and can be caught with try/catch: a value that does
|
||||
not fit its type, an ident that is not in the allow list, a bind
|
||||
outside an sql tag, a bind with no value, an unknown type, and a
|
||||
statement whose number of ? placeholders differs from its number of
|
||||
bind tags. The error text never contains the bound value itself.
|
||||
|
||||
To find the sql tags that still write values into the statement text,
|
||||
run the jet compiler's lint over a site:
|
||||
|
||||
\begin{verbatim}
|
||||
jetc --lint-sql /path/to/site
|
||||
\end{verbatim}
|
||||
|
||||
It prints the file and line of each one, with the variables it uses.
|
||||
Add \texttt{-{}-strict} to include values from the rows of an earlier query.
|
||||
|
||||
\section{call}
|
||||
|
||||
Use the call tag to evoke an executable file from a jet script.
|
||||
|
||||
The atrributes are:
|
||||
|
||||
pgm
|
||||
|
||||
argn
|
||||
|
||||
name
|
||||
|
||||
input
|
||||
|
||||
error
|
||||
|
||||
The call tag is unscoped.
|
||||
|
||||
\begin{verbatim}
|
||||
<call pgm="ls" arg1="-al" name="listing" />
|
||||
\end{verbatim}
|
||||
|
||||
will call the ls command with parameter -al and place the output into
|
||||
a variable named 'listing'.
|
||||
|
||||
\section{comment}
|
||||
|
||||
Use the comment tag to create a section in the jet script that can be
|
||||
used for making comments and is ignored by the jet reader.
|
||||
|
||||
The comments tag has no attributes.
|
||||
|
||||
\section{cookie}
|
||||
|
||||
Use the cookie tag to specify a cookie when using the CGI features
|
||||
of JET.
|
||||
|
||||
\section{dump}
|
||||
|
||||
Use the dump tag to display the contents of all the global, local and
|
||||
cgi cariables to a specified file.
|
||||
|
||||
The attributes are:
|
||||
|
||||
file
|
||||
|
||||
\section{exclude}
|
||||
|
||||
Use the exclude tag to exclude a conainer contents from normal parsing
|
||||
and variable resolution.
|
||||
|
||||
\section{expr}
|
||||
|
||||
\section{for}
|
||||
|
||||
Use the for tag to iterate a tag container for a logical number of
|
||||
times.
|
||||
|
||||
The attributes are:
|
||||
|
||||
start
|
||||
|
||||
end
|
||||
|
||||
step
|
||||
|
||||
name - defines a name for the iterator that will be available within
|
||||
the loop.
|
||||
|
||||
scope - defines the scope of the iterator for the loop.
|
||||
|
||||
\section{header}
|
||||
|
||||
Use the header tag to output a header prior to outputting the process
|
||||
buffer to the requester.
|
||||
|
||||
The attributes are:
|
||||
|
||||
name
|
||||
|
||||
expr
|
||||
|
||||
value
|
||||
|
||||
container
|
||||
|
||||
\section{if/else}
|
||||
|
||||
Use the if tag to perform a conditional output on the tag container.
|
||||
An optional else container provides alternate output in the event the
|
||||
condition is not met.
|
||||
|
||||
The attributes are:
|
||||
|
||||
value1
|
||||
|
||||
value2
|
||||
|
||||
type
|
||||
|
||||
expr
|
||||
|
||||
\section{ifrow/else}
|
||||
|
||||
Use the ifrow tag to output the tag container if a row exists in the
|
||||
mysql tag. An optional else container provides alternate output in the
|
||||
event that there is no row for the sql result.
|
||||
|
||||
The attributes are:
|
||||
|
||||
sessionid
|
||||
|
||||
\section{include}
|
||||
|
||||
Use the include tag to include another content file at the location of
|
||||
the include tag.
|
||||
|
||||
The attributes are:
|
||||
|
||||
file
|
||||
|
||||
\section{jet}
|
||||
|
||||
Use the jet tag to specify parameters for the jet parsing session and
|
||||
to control the output options.
|
||||
|
||||
\section{mysql}
|
||||
|
||||
Use the mysql tag to specify parameters for connecting to a mysql
|
||||
server. The container of the tag is where you can specify the sql
|
||||
statement and method of processing the result output of the executed
|
||||
sql statement. The mysql session created is valid only withon the
|
||||
container of this tag.
|
||||
|
||||
The attributes are:
|
||||
|
||||
host
|
||||
|
||||
database
|
||||
|
||||
user
|
||||
|
||||
password
|
||||
|
||||
sessionid
|
||||
|
||||
\section{read}
|
||||
|
||||
Use the read tag to read the contents of a file contained on the local
|
||||
file system into a variable for further output or processing.
|
||||
|
||||
The attributes are:
|
||||
|
||||
file
|
||||
|
||||
name
|
||||
|
||||
\section{set}
|
||||
|
||||
Use the set tag to store initialize a variable to a value contained in
|
||||
a value attribute, the result of an expression (expr) attribute or the
|
||||
contents of the set tag container.
|
||||
|
||||
The attributes are:
|
||||
|
||||
name
|
||||
|
||||
expr
|
||||
|
||||
value
|
||||
|
||||
container
|
||||
|
||||
scope - where the variable is stored. The values are:
|
||||
|
||||
\begin{itemize}
|
||||
\item global - the default. Available to all logic for the rest of the
|
||||
request.
|
||||
\item local - available only within the container where it is set.
|
||||
\item parent - stored in the scope of the enclosing tag.
|
||||
\item session - stored in the session file and kept across requests.
|
||||
Requires session control. See Session Variables.
|
||||
\end{itemize}
|
||||
|
||||
\section{sql}
|
||||
|
||||
Use the sql tag to specify an sql statement to run on the sql server
|
||||
specified in the mysql tag.
|
||||
|
||||
As long as sql statements are executed within the same mysql
|
||||
containing tag then the same mysql session is used for each sql
|
||||
statement.
|
||||
|
||||
Values that come from a request, a cookie or a session should be
|
||||
passed with bind tags and ? placeholders rather than written into the
|
||||
statement text. See the bind tag.
|
||||
|
||||
\begin{verbatim}
|
||||
<sql>delete from cart_item where session_uuid=? and sku=?
|
||||
<bind value="$[_session_id]">
|
||||
<bind value="$[sku]">
|
||||
</sql>
|
||||
\end{verbatim}
|
||||
|
||||
A statement that changes the connection character set (SET NAMES, SET
|
||||
CHARACTER SET and similar) is refused. The connection always uses
|
||||
utf8mb4.
|
||||
|
||||
The attributes are:
|
||||
|
||||
sessionid
|
||||
|
||||
container
|
||||
|
||||
\section{stream}
|
||||
|
||||
Use stream tag to output data from the server without waiting for the
|
||||
standard output buffering and processing of the JET script. This is
|
||||
useful for outputting images and streams for audio and video without
|
||||
the server having to load the whole thing into RAM first.
|
||||
|
||||
The attributes are:
|
||||
|
||||
file
|
||||
|
||||
\section{system}
|
||||
|
||||
Use the system tag to execute a bash shell command within the JET
|
||||
script.
|
||||
|
||||
\section{tag}
|
||||
|
||||
Use the tag tag to define a new tag definition for use within the
|
||||
script.
|
||||
|
||||
Tags are normally defined globally and can be used anywhere within the
|
||||
script.
|
||||
|
||||
Tags can also be defined within other tags and the scope of those tags
|
||||
is only within the defining tag's container. The enclosed tag
|
||||
definition will not be available globally.
|
||||
|
||||
\section{until}
|
||||
|
||||
Use the until tag to process a container at least once and
|
||||
continue to process the container until the specified condition is met.
|
||||
|
||||
Note that this tag always processes the container at least once.
|
||||
|
||||
Be careful not to create a never ending loop by not modifying any of
|
||||
the condition parameters specified in the condition clause.
|
||||
|
||||
\section{while}
|
||||
|
||||
Use the while tag to process a container if the specified condition is
|
||||
true.
|
||||
|
||||
Note that the container may not be processed if the condition is never
|
||||
met.
|
||||
|
||||
Be careful not to create a never ending loop by not modifying any of
|
||||
the condition parameters specified in the condition clause.
|
||||
|
||||
\section{whiledir}
|
||||
|
||||
Use the whiledir tag to loop a directory path to the container for
|
||||
processing.
|
||||
|
||||
\section{whilerow}
|
||||
|
||||
Use the whilerow tag in combination with mysql and sql tags to provide
|
||||
a container to process for each row retrieved by the sql statement.
|
||||
|
||||
\section{write}
|
||||
|
||||
Use the write tag to write data to the local file system.
|
||||
|
||||
\end{document}
|
||||
@@ -0,0 +1,238 @@
|
||||
# Design: bound parameters for `<sql>`
|
||||
|
||||
**Status:** phases 1 and 2 implemented (2026-11-20) · **Author:** Brad Arant (drafted with Claude) · **Date:** 2026-10-23
|
||||
**Applies to:** JetCore (`__sql`, `__mysql`, `Tag.cpp` tag dispatch, `jetc` parser/codegen)
|
||||
|
||||
## 1. The problem
|
||||
|
||||
`<sql>` builds its query by rendering its body as text, then sending the finished
|
||||
string to MySQL:
|
||||
|
||||
```cpp
|
||||
// __sql.cpp today
|
||||
processContainer(container); // every $[...] substituted as plain text
|
||||
global.getSession(sessionId)->query(out); // mysql_real_query(the whole string)
|
||||
```
|
||||
|
||||
So a request value lands *inside the SQL text*:
|
||||
|
||||
```html
|
||||
<sql>select id from users where email='$[email]' and secret='$[password]'</sql>
|
||||
```
|
||||
|
||||
With `email = x' or '1'='1' -- ` that becomes a different query. There is no
|
||||
escaping function in Jet, so this is the only way to write a query, and it's
|
||||
unsafe everywhere a value comes from a request. Numeric positions are worse:
|
||||
`where id=$[id]` has no quotes, so even escaping wouldn't help (`id = 1 or 1=1`).
|
||||
|
||||
Measured on 2026-10-23 (`<sql>` blocks whose body contains a request/session
|
||||
value other than `$[.column]`, `$[_login_id]` or `$[_session_id]`):
|
||||
|
||||
| Site | `<sql>` blocks | with values pasted in | files |
|
||||
|---|---:|---:|---:|
|
||||
| barant.com | 152 | 117 | 64 |
|
||||
| ClockPlanet | 94 | 83 | 35 |
|
||||
|
||||
Roughly 80% of all queries. Login, signup, cart, checkout and admin pages are
|
||||
all in that set.
|
||||
|
||||
## 2. Goals
|
||||
|
||||
1. A way to pass values to `<sql>` that **can never change the query's meaning**,
|
||||
whatever they contain.
|
||||
2. **No change to how results are read** - `<ifrow>`, `<whilerow>`, `$[.column]`,
|
||||
`$[?N]`, `$[#]` keep working exactly as today.
|
||||
3. Easy, mechanical migration of existing pages; old pages keep running until migrated.
|
||||
4. A path to *enforcing* it, so new unsafe queries can't be written by accident.
|
||||
|
||||
Non-goals: an ORM, query builders, or changing `<database>`/`<mysql>` connection handling.
|
||||
|
||||
## 3. Proposed syntax
|
||||
|
||||
Placeholders are `?` in the query; values come from `<bind>` tags inside the
|
||||
`<sql>`, in order:
|
||||
|
||||
```html
|
||||
<sql>
|
||||
select id, name from users where email=? and status=?
|
||||
<bind value="$[email]">
|
||||
<bind value="ACTIVE">
|
||||
</sql>
|
||||
```
|
||||
|
||||
`<bind>` attributes:
|
||||
|
||||
| attribute | meaning |
|
||||
|---|---|
|
||||
| `value` | the value (any Jet expression - `$[...]` is fine here, that's the point) |
|
||||
| `type` | `string` (default), `int`, `decimal`, `bool`, `date`, `datetime`, `ident` |
|
||||
| `null` | `empty` = bind SQL `NULL` when the value is empty (default: bind `''`) |
|
||||
| `allow` | for `type="ident"` only: comma list of permitted identifiers |
|
||||
|
||||
Type behaviour (a value that doesn't fit throws a catchable Jet exception -
|
||||
`<try>`/`<catch>` works, see §6):
|
||||
|
||||
- `string` - quoted and escaped (§4).
|
||||
- `int` - must match `^-?[0-9]{1,19}$`; emitted bare. This fixes the unquoted
|
||||
`where id=$[id]` case.
|
||||
- `decimal` - must match `^-?[0-9]{1,30}(\.[0-9]{1,30})?$`; emitted bare.
|
||||
- `bool` - `1/0/true/false/yes/no` → `1`/`0`.
|
||||
- `date` / `datetime` - must parse as `YYYY-MM-DD` / `YYYY-MM-DD HH:MM[:SS]`; quoted.
|
||||
- `ident` - for the things SQL can't parameterise (column in `ORDER BY`, a sort
|
||||
direction, a table name). The value must be in `allow` or it throws; emitted
|
||||
backtick-quoted (`ASC`/`DESC` emitted bare). Example:
|
||||
|
||||
```html
|
||||
<sql>select * from products order by ? ?
|
||||
<bind value="$[sort]" type="ident" allow="name,price,created">
|
||||
<bind value="$[dir]" type="ident" allow="ASC,DESC">
|
||||
</sql>
|
||||
```
|
||||
|
||||
Why `<bind>` and not `<param>`: `param` is an HTML element (inside `<object>`),
|
||||
and `jetc`'s void-tag list treats it as HTML. A Jet-only name avoids any ambiguity.
|
||||
|
||||
Why positional `?` and not named (`:email`): `?` is what MySQL and every SQL
|
||||
library uses, it needs no new attribute-name syntax in the parser, and the
|
||||
`<bind>` lines sit right under the query so the order is easy to read. Named
|
||||
binds can be added later without breaking this (§9).
|
||||
|
||||
## 4. How it works
|
||||
|
||||
### Emulated binding (recommended for phase 1)
|
||||
|
||||
`__sql` collects the `<bind>` values while its body renders, then replaces each
|
||||
`?` that is **outside** a string literal, backtick identifier or comment with the
|
||||
bound value, rendered safely - and only then calls `query()` as today.
|
||||
|
||||
- Strings are escaped with `mysql_real_escape_string_quote(mysql, to, from, len, '\'')`
|
||||
and wrapped in single quotes. This uses the *connection's* character set and
|
||||
respects `NO_BACKSLASH_ESCAPES`, which plain `mysql_real_escape_string` doesn't.
|
||||
- The connection's character set is pinned at connect time
|
||||
(`mysql_options(MYSQL_SET_CHARSET_NAME, "utf8mb4")` in `__mysql`), so escaping
|
||||
and server parsing always agree. `<sql>` refuses a `SET NAMES`/`SET CHARACTER SET`
|
||||
statement (the classic way to make escaping and parsing disagree).
|
||||
- Number of `?` must equal number of `<bind>`s, otherwise throw
|
||||
`"sql: 3 placeholders but 2 bind values"`.
|
||||
|
||||
This is the same approach PHP's PDO uses by default. Its big advantage here:
|
||||
**the result path doesn't change at all** - `query()` still runs
|
||||
`mysql_real_query` and `mysql_store_result`, so `MYSQL_ROW`, `getColumnValue()`,
|
||||
`<ifrow>`, `<whilerow>` and the column-index map are untouched.
|
||||
|
||||
### Why not real server-side prepared statements (yet)
|
||||
|
||||
`mysql_stmt_*` returns rows through typed bind buffers, not `MYSQL_ROW`, so
|
||||
`getColumnValue()`, `$[?N]`, `$[#]` and the field-index map would all need a
|
||||
second implementation, and some statements (multi-statements, some DDL) can't be
|
||||
prepared. That's a bigger change for no extra safety over correct emulation.
|
||||
It stays open as a later option (§9), behind the same `<bind>` syntax, so pages
|
||||
written now won't need touching again.
|
||||
|
||||
### Code shape
|
||||
|
||||
- **New** `__bind.h/.cpp`: on construction, find the nearest enclosing `__sql`
|
||||
(walk `parent` with `dynamic_cast<__sql*>`; throw `"bind must be inside sql"`
|
||||
if none), resolve `value`/`type`/`null`/`allow`, validate per type, and call
|
||||
`sql->addBind(...)`. Produces no output.
|
||||
- **`__sql`**: a `std::vector<BoundValue>` member and `addBind()`. After
|
||||
`processContainer(container)`, run `bindPlaceholders(out)` - a small scanner
|
||||
that tracks `'...'` (with `''` and `\'`), `"..."`, `` `...` ``, `-- `, `#` and
|
||||
`/* */` so `?` inside them is left alone - then `query(result)`.
|
||||
- **`__mysql`**: `escapeString(const MString&)` wrapper around
|
||||
`mysql_real_escape_string_quote`; pin `utf8mb4` at connect.
|
||||
- **`Tag.cpp`**: add `ifTagName(in, "bind")` next to `sql` (line ~494).
|
||||
- **`jetc` `JetParser.cpp`**: add `"bind"` to the Jet void-tag list (it has no
|
||||
closing tag); **`JetCodegen.cpp`**: emit `__bind` like the other tags.
|
||||
|
||||
Estimated size: ~200 lines plus tests.
|
||||
|
||||
## 5. Existing pages: nothing breaks
|
||||
|
||||
A `<sql>` with no `<bind>` runs exactly as today - no `?` replacement at all,
|
||||
so existing queries containing a literal `?` are unaffected. Migration is
|
||||
page by page:
|
||||
|
||||
```html
|
||||
<!-- before -->
|
||||
<sql>select * from users where email="$[email]" and status="CONFIRM"</sql>
|
||||
<!-- after -->
|
||||
<sql>select * from users where email=? and status="CONFIRM"
|
||||
<bind value="$[email]">
|
||||
</sql>
|
||||
|
||||
<!-- before: unquoted number, injectable even with escaping -->
|
||||
<sql>delete from cart_item where session_uuid='$[_session_id]' and sku='$[sku]'</sql>
|
||||
<!-- after -->
|
||||
<sql>delete from cart_item where session_uuid=? and sku=?
|
||||
<bind value="$[_session_id]">
|
||||
<bind value="$[sku]">
|
||||
</sql>
|
||||
```
|
||||
|
||||
## 6. Errors
|
||||
|
||||
- Bad `<bind>` value (wrong type, ident not allowed), placeholder/bind count
|
||||
mismatch, `<bind>` outside `<sql>`: throw `coreutils::Exception` with a clear
|
||||
message, caught by `<try>`/`<catch>` like the MySQL errors fixed on 2026-09-13.
|
||||
- The exception text never includes the bound value itself (it may be a password).
|
||||
|
||||
## 7. Enforcement
|
||||
|
||||
Once pages are migrated, make the unsafe form an error instead of a habit:
|
||||
|
||||
1. **`jetc --lint-sql`** - lists every `<sql>` whose body contains `$[...]`
|
||||
other than `$[.column]` (row values from an outer query), with file:line.
|
||||
This is the migration worklist (§8) and a CI check.
|
||||
|
||||
As implemented (`jetc/JetLint.cpp`): `jetc --lint-sql [--strict] <file|dir>...`
|
||||
scans every file under the given paths. It reports `$[...]` and local
|
||||
`#[...]` references, with the kind of each (`global`, `cgi`, `session`,
|
||||
`env`, `keyword`, `local`). Row values (`$[.col]`, `$[session.col]`,
|
||||
`$[?N]`, `$[#]`, `$[?#]`) are not reported unless `--strict` is given.
|
||||
References in the attributes of `<bind>`, `<if>`, `<else>`, `<ifrow>`,
|
||||
`<while>`, `<whilerow>`, `<until>`, `<for>` and `<set>` are not reported,
|
||||
since those never become statement text; nor is anything inside
|
||||
`<comment>` or `|> <|`. A custom tag defined as `<sql ...><container></sql>`
|
||||
(barant.com's `<showtable>`) takes its statement from the caller's content,
|
||||
so each use of it is checked like an `<sql>`. Exit status: 0 nothing found,
|
||||
1 findings, 2 a path could not be read. Tests: `tests/runlinttests.sh`.
|
||||
2. **Per-site strict mode** - an APIServer site setting
|
||||
`"sqlInterpolation": "warn" | "error"`. In `error` mode `<sql>` refuses to run
|
||||
if its body substituted any `$[...]` except `$[.column]`; `warn` logs it.
|
||||
Default `warn` for existing sites, `error` for new ones.
|
||||
3. **Escape hatch** - `<sql raw="yes">` for the rare trusted dynamic SQL
|
||||
(generated by the site itself, never from input), so it's visible in review
|
||||
and greppable.
|
||||
|
||||
## 8. Migration plan
|
||||
|
||||
| Phase | What | Notes |
|
||||
|---|---|---|
|
||||
| 1 | Implement `<bind>`, escaping, utf8mb4 pinning, tests | JetCore only; no page changes. Done 2026-11-20 |
|
||||
| 2 | `jetc --lint-sql`; run on both sites | produces the worklist (≈200 queries). Done 2026-11-20 on the local copies: see [sql-lint-worklist.md](sql-lint-worklist.md) |
|
||||
| 3 | Convert the high-risk pages first | login/signup/password reset, cart/checkout/payment (`pp.jet`), admin procs, ClockPlanet `mobile_api.jet` and auth |
|
||||
| 4 | Convert the rest; turn on `warn` | logs show anything missed |
|
||||
| 5 | Switch both sites to `error` | unsafe queries can no longer ship |
|
||||
|
||||
Phase 3 is the one that matters most for security and is a few days' work;
|
||||
each conversion is mechanical and testable page by page.
|
||||
|
||||
## 9. Later
|
||||
|
||||
- Named binds: `where email=:email` + `<bind name="email" value="...">`.
|
||||
- Real prepared statements (`mysql_stmt_*`) behind the same `<bind>` syntax.
|
||||
- The companion fix for output: HTML-escape `$[...]` by default with an explicit
|
||||
raw form - the same "safe unless you say otherwise" rule for the other half of
|
||||
the injection problem (cross-site scripting).
|
||||
|
||||
## 10. Tests
|
||||
|
||||
- Every type: valid values bind correctly; invalid values throw.
|
||||
- Injection strings (`' or '1'='1`, `\'`, multibyte sequences such as `0xbf27`,
|
||||
`--`, `;`, NUL bytes) are stored and read back byte-for-byte unchanged.
|
||||
- `?` inside `'...'`, `"..."`, `` `...` ``, `--`, `#` and `/* */` is never replaced.
|
||||
- Placeholder/bind count mismatch throws; `<bind>` outside `<sql>` throws.
|
||||
- A `<sql>` with no binds produces exactly the same query text as before.
|
||||
- `<ifrow>`/`<whilerow>`/`$[.col]`/`$[?N]`/`$[#]` behave identically on bound queries.
|
||||
- `NO_BACKSLASH_ESCAPES` on and off.
|
||||
@@ -0,0 +1,576 @@
|
||||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesPackage{doxygen}
|
||||
|
||||
% Packages used by this style file
|
||||
\RequirePackage{alltt}
|
||||
%%\RequirePackage{array} %% moved to refman.tex due to workaround for LaTex 2019 version and unmaintained tabu package
|
||||
\RequirePackage{calc}
|
||||
\RequirePackage{float}
|
||||
%%\RequirePackage{ifthen} %% moved to refman.tex due to workaround for LaTex 2019 version and unmaintained tabu package
|
||||
\RequirePackage{verbatim}
|
||||
\RequirePackage[table]{xcolor}
|
||||
\RequirePackage{longtable_doxygen}
|
||||
\RequirePackage{tabu_doxygen}
|
||||
\RequirePackage{fancyvrb}
|
||||
\RequirePackage{tabularx}
|
||||
\RequirePackage{multirow}
|
||||
\RequirePackage{hanging}
|
||||
\RequirePackage{ifpdf}
|
||||
\RequirePackage{adjustbox}
|
||||
\RequirePackage{amssymb}
|
||||
\RequirePackage{stackengine}
|
||||
\RequirePackage[normalem]{ulem} % for strikeout, but don't modify emphasis
|
||||
|
||||
%---------- Internal commands used in this style file ----------------
|
||||
|
||||
\newcommand{\ensurespace}[1]{%
|
||||
\begingroup%
|
||||
\setlength{\dimen@}{#1}%
|
||||
\vskip\z@\@plus\dimen@%
|
||||
\penalty -100\vskip\z@\@plus -\dimen@%
|
||||
\vskip\dimen@%
|
||||
\penalty 9999%
|
||||
\vskip -\dimen@%
|
||||
\vskip\z@skip% hide the previous |\vskip| from |\addvspace|
|
||||
\endgroup%
|
||||
}
|
||||
|
||||
\newcommand{\DoxyHorRuler}[1]{%
|
||||
\setlength{\parskip}{0ex plus 0ex minus 0ex}%
|
||||
\ifthenelse{#1=0}%
|
||||
{%
|
||||
\hrule%
|
||||
}%
|
||||
{%
|
||||
\hrulefilll%
|
||||
}%
|
||||
}
|
||||
\newcommand{\DoxyLabelFont}{}
|
||||
\newcommand{\entrylabel}[1]{%
|
||||
{%
|
||||
\parbox[b]{\labelwidth-4pt}{%
|
||||
\makebox[0pt][l]{\DoxyLabelFont#1}%
|
||||
\vspace{1.5\baselineskip}%
|
||||
}%
|
||||
}%
|
||||
}
|
||||
|
||||
\newenvironment{DoxyDesc}[1]{%
|
||||
\ensurespace{4\baselineskip}%
|
||||
\begin{list}{}{%
|
||||
\settowidth{\labelwidth}{20pt}%
|
||||
%\setlength{\parsep}{0pt}%
|
||||
\setlength{\itemsep}{0pt}%
|
||||
\setlength{\leftmargin}{\labelwidth+\labelsep}%
|
||||
\renewcommand{\makelabel}{\entrylabel}%
|
||||
}%
|
||||
\item[#1]%
|
||||
}{%
|
||||
\end{list}%
|
||||
}
|
||||
|
||||
\newsavebox{\xrefbox}
|
||||
\newlength{\xreflength}
|
||||
\newcommand{\xreflabel}[1]{%
|
||||
\sbox{\xrefbox}{#1}%
|
||||
\setlength{\xreflength}{\wd\xrefbox}%
|
||||
\ifthenelse{\xreflength>\labelwidth}{%
|
||||
\begin{minipage}{\textwidth}%
|
||||
\setlength{\parindent}{0pt}%
|
||||
\hangindent=15pt\bfseries #1\vspace{1.2\itemsep}%
|
||||
\end{minipage}%
|
||||
}{%
|
||||
\parbox[b]{\labelwidth}{\makebox[0pt][l]{\textbf{#1}}}%
|
||||
}%
|
||||
}
|
||||
|
||||
%---------- Commands used by doxygen LaTeX output generator ----------
|
||||
|
||||
% Used by <pre> ... </pre>
|
||||
\newenvironment{DoxyPre}{%
|
||||
\small%
|
||||
\begin{alltt}%
|
||||
}{%
|
||||
\end{alltt}%
|
||||
\normalsize%
|
||||
}
|
||||
% Necessary for redefining not defined characters, i.e. "Replacement Character" in tex output.
|
||||
\newlength{\CodeWidthChar}
|
||||
\newlength{\CodeHeightChar}
|
||||
\settowidth{\CodeWidthChar}{?}
|
||||
\settoheight{\CodeHeightChar}{?}
|
||||
% Necessary for hanging indent
|
||||
\newlength{\DoxyCodeWidth}
|
||||
|
||||
\newcommand\DoxyCodeLine[1]{\hangpara{\DoxyCodeWidth}{1}{#1}\par}
|
||||
|
||||
\newcommand\NiceSpace{%
|
||||
\discretionary{}{\kern\fontdimen2\font}{\kern\fontdimen2\font}%
|
||||
}
|
||||
|
||||
% Used by @code ... @endcode
|
||||
\newenvironment{DoxyCode}[1]{%
|
||||
\par%
|
||||
\scriptsize%
|
||||
\normalfont\ttfamily%
|
||||
\rightskip0pt plus 1fil%
|
||||
\settowidth{\DoxyCodeWidth}{000000}%
|
||||
\settowidth{\CodeWidthChar}{?}%
|
||||
\settoheight{\CodeHeightChar}{?}%
|
||||
\setlength{\parskip}{0ex plus 0ex minus 0ex}%
|
||||
\ifthenelse{\equal{#1}{0}}
|
||||
{
|
||||
{\lccode`~32 \lowercase{\global\let~}\NiceSpace}\obeyspaces%
|
||||
}
|
||||
{
|
||||
{\lccode`~32 \lowercase{\global\let~}}\obeyspaces%
|
||||
}
|
||||
|
||||
}{%
|
||||
\normalfont%
|
||||
\normalsize%
|
||||
\settowidth{\CodeWidthChar}{?}%
|
||||
\settoheight{\CodeHeightChar}{?}%
|
||||
}
|
||||
|
||||
% Redefining not defined characters, i.e. "Replacement Character" in tex output.
|
||||
\def\ucr{\adjustbox{width=\CodeWidthChar,height=\CodeHeightChar}{\stackinset{c}{}{c}{-.2pt}{%
|
||||
\textcolor{white}{\sffamily\bfseries\small ?}}{%
|
||||
\rotatebox{45}{$\blacksquare$}}}}
|
||||
|
||||
% Used by @example, @include, @includelineno and @dontinclude
|
||||
\newenvironment{DoxyCodeInclude}[1]{%
|
||||
\DoxyCode{#1}%
|
||||
}{%
|
||||
\endDoxyCode%
|
||||
}
|
||||
|
||||
% Used by @verbatim ... @endverbatim
|
||||
\newenvironment{DoxyVerb}{%
|
||||
\footnotesize%
|
||||
\verbatim%
|
||||
}{%
|
||||
\endverbatim%
|
||||
\normalsize%
|
||||
}
|
||||
|
||||
% Used by @verbinclude
|
||||
\newenvironment{DoxyVerbInclude}{%
|
||||
\DoxyVerb%
|
||||
}{%
|
||||
\endDoxyVerb%
|
||||
}
|
||||
|
||||
% Used by numbered lists (using '-#' or <ol> ... </ol>)
|
||||
\newenvironment{DoxyEnumerate}{%
|
||||
\enumerate%
|
||||
}{%
|
||||
\endenumerate%
|
||||
}
|
||||
|
||||
% Used by bullet lists (using '-', @li, @arg, or <ul> ... </ul>)
|
||||
\newenvironment{DoxyItemize}{%
|
||||
\itemize%
|
||||
}{%
|
||||
\enditemize%
|
||||
}
|
||||
|
||||
% Used by description lists (using <dl> ... </dl>)
|
||||
\newenvironment{DoxyDescription}{%
|
||||
\description%
|
||||
}{%
|
||||
\enddescription%
|
||||
}
|
||||
|
||||
% Used by @image, @dotfile, @dot ... @enddot, and @msc ... @endmsc
|
||||
% (only if caption is specified)
|
||||
\newenvironment{DoxyImage}{%
|
||||
\begin{figure}[H]%
|
||||
\begin{center}%
|
||||
}{%
|
||||
\end{center}%
|
||||
\end{figure}%
|
||||
}
|
||||
|
||||
% Used by @image, @dotfile, @dot ... @enddot, and @msc ... @endmsc
|
||||
% (only if no caption is specified)
|
||||
\newenvironment{DoxyImageNoCaption}{%
|
||||
\begin{center}%
|
||||
}{%
|
||||
\end{center}%
|
||||
}
|
||||
|
||||
% Used by @image
|
||||
% (only if inline is specified)
|
||||
\newenvironment{DoxyInlineImage}{%
|
||||
}{%
|
||||
}
|
||||
|
||||
% Used by @attention
|
||||
\newenvironment{DoxyAttention}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @author and @authors
|
||||
\newenvironment{DoxyAuthor}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @date
|
||||
\newenvironment{DoxyDate}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @invariant
|
||||
\newenvironment{DoxyInvariant}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @note
|
||||
\newenvironment{DoxyNote}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @post
|
||||
\newenvironment{DoxyPostcond}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @pre
|
||||
\newenvironment{DoxyPrecond}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @copyright
|
||||
\newenvironment{DoxyCopyright}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @remark
|
||||
\newenvironment{DoxyRemark}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @return and @returns
|
||||
\newenvironment{DoxyReturn}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @since
|
||||
\newenvironment{DoxySince}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @see
|
||||
\newenvironment{DoxySeeAlso}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @version
|
||||
\newenvironment{DoxyVersion}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @warning
|
||||
\newenvironment{DoxyWarning}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by @internal
|
||||
\newenvironment{DoxyInternal}[1]{%
|
||||
\paragraph*{#1}%
|
||||
}{%
|
||||
}
|
||||
|
||||
% Used by @par and @paragraph
|
||||
\newenvironment{DoxyParagraph}[1]{%
|
||||
\begin{DoxyDesc}{#1}%
|
||||
}{%
|
||||
\end{DoxyDesc}%
|
||||
}
|
||||
|
||||
% Used by parameter lists
|
||||
\newenvironment{DoxyParams}[2][]{%
|
||||
\tabulinesep=1mm%
|
||||
\par%
|
||||
\ifthenelse{\equal{#1}{}}%
|
||||
{\begin{longtabu*}spread 0pt [l]{|X[-1,l]|X[-1,l]|}}% name + description
|
||||
{\ifthenelse{\equal{#1}{1}}%
|
||||
{\begin{longtabu*}spread 0pt [l]{|X[-1,l]|X[-1,l]|X[-1,l]|}}% in/out + name + desc
|
||||
{\begin{longtabu*}spread 0pt [l]{|X[-1,l]|X[-1,l]|X[-1,l]|X[-1,l]|}}% in/out + type + name + desc
|
||||
}
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #2}\\[1ex]%
|
||||
\hline%
|
||||
\endfirsthead%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #2}\\[1ex]%
|
||||
\hline%
|
||||
\endhead%
|
||||
}{%
|
||||
\end{longtabu*}%
|
||||
\vspace{6pt}%
|
||||
}
|
||||
|
||||
% Used for fields of simple structs
|
||||
\newenvironment{DoxyFields}[1]{%
|
||||
\tabulinesep=1mm%
|
||||
\par%
|
||||
\begin{longtabu*}spread 0pt [l]{|X[-1,r]|X[-1,l]|X[-1,l]|}%
|
||||
\multicolumn{3}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endfirsthead%
|
||||
\multicolumn{3}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endhead%
|
||||
}{%
|
||||
\end{longtabu*}%
|
||||
\vspace{6pt}%
|
||||
}
|
||||
|
||||
% Used for fields simple class style enums
|
||||
\newenvironment{DoxyEnumFields}[1]{%
|
||||
\tabulinesep=1mm%
|
||||
\par%
|
||||
\begin{longtabu*}spread 0pt [l]{|X[-1,r]|X[-1,l]|}%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endfirsthead%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endhead%
|
||||
}{%
|
||||
\end{longtabu*}%
|
||||
\vspace{6pt}%
|
||||
}
|
||||
|
||||
% Used for parameters within a detailed function description
|
||||
\newenvironment{DoxyParamCaption}{%
|
||||
\renewcommand{\item}[2][]{\\ \hspace*{2.0cm} ##1 {\em ##2}}%
|
||||
}{%
|
||||
}
|
||||
|
||||
% Used by return value lists
|
||||
\newenvironment{DoxyRetVals}[1]{%
|
||||
\tabulinesep=1mm%
|
||||
\par%
|
||||
\begin{longtabu*}spread 0pt [l]{|X[-1,r]|X[-1,l]|}%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endfirsthead%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endhead%
|
||||
}{%
|
||||
\end{longtabu*}%
|
||||
\vspace{6pt}%
|
||||
}
|
||||
|
||||
% Used by exception lists
|
||||
\newenvironment{DoxyExceptions}[1]{%
|
||||
\tabulinesep=1mm%
|
||||
\par%
|
||||
\begin{longtabu*}spread 0pt [l]{|X[-1,r]|X[-1,l]|}%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endfirsthead%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endhead%
|
||||
}{%
|
||||
\end{longtabu*}%
|
||||
\vspace{6pt}%
|
||||
}
|
||||
|
||||
% Used by template parameter lists
|
||||
\newenvironment{DoxyTemplParams}[1]{%
|
||||
\tabulinesep=1mm%
|
||||
\par%
|
||||
\begin{longtabu*}spread 0pt [l]{|X[-1,r]|X[-1,l]|}%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endfirsthead%
|
||||
\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]%
|
||||
\hline%
|
||||
\endhead%
|
||||
}{%
|
||||
\end{longtabu*}%
|
||||
\vspace{6pt}%
|
||||
}
|
||||
|
||||
% Used for member lists
|
||||
\newenvironment{DoxyCompactItemize}{%
|
||||
\begin{itemize}%
|
||||
\setlength{\itemsep}{-3pt}%
|
||||
\setlength{\parsep}{0pt}%
|
||||
\setlength{\topsep}{0pt}%
|
||||
\setlength{\partopsep}{0pt}%
|
||||
}{%
|
||||
\end{itemize}%
|
||||
}
|
||||
|
||||
% Used for member descriptions
|
||||
\newenvironment{DoxyCompactList}{%
|
||||
\begin{list}{}{%
|
||||
\setlength{\leftmargin}{0.5cm}%
|
||||
\setlength{\itemsep}{0pt}%
|
||||
\setlength{\parsep}{0pt}%
|
||||
\setlength{\topsep}{0pt}%
|
||||
\renewcommand{\makelabel}{\hfill}%
|
||||
}%
|
||||
}{%
|
||||
\end{list}%
|
||||
}
|
||||
|
||||
% Used for reference lists (@bug, @deprecated, @todo, etc.)
|
||||
\newenvironment{DoxyRefList}{%
|
||||
\begin{list}{}{%
|
||||
\setlength{\labelwidth}{10pt}%
|
||||
\setlength{\leftmargin}{\labelwidth}%
|
||||
\addtolength{\leftmargin}{\labelsep}%
|
||||
\renewcommand{\makelabel}{\xreflabel}%
|
||||
}%
|
||||
}{%
|
||||
\end{list}%
|
||||
}
|
||||
|
||||
% Used by @bug, @deprecated, @todo, etc.
|
||||
\newenvironment{DoxyRefDesc}[1]{%
|
||||
\begin{list}{}{%
|
||||
\renewcommand\makelabel[1]{\textbf{##1}}%
|
||||
\settowidth\labelwidth{\makelabel{#1}}%
|
||||
\setlength\leftmargin{\labelwidth+\labelsep}%
|
||||
}%
|
||||
}{%
|
||||
\end{list}%
|
||||
}
|
||||
|
||||
% Used by parameter lists and simple sections
|
||||
\newenvironment{Desc}
|
||||
{\begin{list}{}{%
|
||||
\settowidth{\labelwidth}{20pt}%
|
||||
\setlength{\parsep}{0pt}%
|
||||
\setlength{\itemsep}{0pt}%
|
||||
\setlength{\leftmargin}{\labelwidth+\labelsep}%
|
||||
\renewcommand{\makelabel}{\entrylabel}%
|
||||
}
|
||||
}{%
|
||||
\end{list}%
|
||||
}
|
||||
|
||||
% Used by tables
|
||||
\newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp}%
|
||||
\newenvironment{TabularC}[1]%
|
||||
{\tabulinesep=1mm
|
||||
\begin{longtabu*}spread 0pt [c]{*#1{|X[-1]}|}}%
|
||||
{\end{longtabu*}\par}%
|
||||
|
||||
\newenvironment{TabularNC}[1]%
|
||||
{\begin{tabu}spread 0pt [l]{*#1{|X[-1]}|}}%
|
||||
{\end{tabu}\par}%
|
||||
|
||||
% Used for member group headers
|
||||
\newenvironment{Indent}{%
|
||||
\begin{list}{}{%
|
||||
\setlength{\leftmargin}{0.5cm}%
|
||||
}%
|
||||
\item[]\ignorespaces%
|
||||
}{%
|
||||
\unskip%
|
||||
\end{list}%
|
||||
}
|
||||
|
||||
% Used when hyperlinks are turned off
|
||||
\newcommand{\doxyref}[3]{%
|
||||
\textbf{#1} (\textnormal{#2}\,\pageref{#3})%
|
||||
}
|
||||
|
||||
% Used to link to a table when hyperlinks are turned on
|
||||
\newcommand{\doxytablelink}[2]{%
|
||||
\ref{#1}%
|
||||
}
|
||||
|
||||
% Used to link to a table when hyperlinks are turned off
|
||||
\newcommand{\doxytableref}[3]{%
|
||||
\ref{#3}%
|
||||
}
|
||||
|
||||
% Used by @addindex
|
||||
\newcommand{\lcurly}{\{}
|
||||
\newcommand{\rcurly}{\}}
|
||||
|
||||
% Colors used for syntax highlighting
|
||||
\definecolor{comment}{rgb}{0.5,0.0,0.0}
|
||||
\definecolor{keyword}{rgb}{0.0,0.5,0.0}
|
||||
\definecolor{keywordtype}{rgb}{0.38,0.25,0.125}
|
||||
\definecolor{keywordflow}{rgb}{0.88,0.5,0.0}
|
||||
\definecolor{preprocessor}{rgb}{0.5,0.38,0.125}
|
||||
\definecolor{stringliteral}{rgb}{0.0,0.125,0.25}
|
||||
\definecolor{charliteral}{rgb}{0.0,0.5,0.5}
|
||||
\definecolor{vhdldigit}{rgb}{1.0,0.0,1.0}
|
||||
\definecolor{vhdlkeyword}{rgb}{0.43,0.0,0.43}
|
||||
\definecolor{vhdllogic}{rgb}{1.0,0.0,0.0}
|
||||
\definecolor{vhdlchar}{rgb}{0.0,0.0,0.0}
|
||||
|
||||
% Color used for table heading
|
||||
\newcommand{\tableheadbgcolor}{lightgray}%
|
||||
|
||||
% Version of hypertarget with correct landing location
|
||||
\newcommand{\Hypertarget}[1]{\Hy@raisedlink{\hypertarget{#1}{}}}
|
||||
|
||||
% possibility to have sections etc. be within the margins
|
||||
% unfortunately had to copy part of book.cls and add \raggedright
|
||||
\makeatletter
|
||||
\newcommand\doxysection{\@startsection {section}{1}{\z@}%
|
||||
{-3.5ex \@plus -1ex \@minus -.2ex}%
|
||||
{2.3ex \@plus.2ex}%
|
||||
{\raggedright\normalfont\Large\bfseries}}
|
||||
\newcommand\doxysubsection{\@startsection{subsection}{2}{\z@}%
|
||||
{-3.25ex\@plus -1ex \@minus -.2ex}%
|
||||
{1.5ex \@plus .2ex}%
|
||||
{\raggedright\normalfont\large\bfseries}}
|
||||
\newcommand\doxysubsubsection{\@startsection{subsubsection}{3}{\z@}%
|
||||
{-3.25ex\@plus -1ex \@minus -.2ex}%
|
||||
{1.5ex \@plus .2ex}%
|
||||
{\raggedright\normalfont\normalsize\bfseries}}
|
||||
\newcommand\doxyparagraph{\@startsection{paragraph}{4}{\z@}%
|
||||
{3.25ex \@plus1ex \@minus.2ex}%
|
||||
{-1em}%
|
||||
{\raggedright\normalfont\normalsize\bfseries}}
|
||||
\newcommand\doxysubparagraph{\@startsection{subparagraph}{5}{\parindent}%
|
||||
{3.25ex \@plus1ex \@minus .2ex}%
|
||||
{-1em}%
|
||||
{\raggedright\normalfont\normalsize\bfseries}}
|
||||
\makeatother
|
||||
% Define caption that is also suitable in a table
|
||||
\makeatletter
|
||||
\def\doxyfigcaption{%
|
||||
\refstepcounter{figure}%
|
||||
\@dblarg{\@caption{figure}}}
|
||||
\makeatother
|
||||
|
After Width: | Height: | Size: 676 B |
|
After Width: | Height: | Size: 635 B |
|
After Width: | Height: | Size: 132 B |
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" width="16" height="24" viewBox="0 0 80 60" id="doc" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g style="fill:#4665A2">
|
||||
<path d="m 14,-1.1445312 c -2.824372,0 -5.1445313,2.320159 -5.1445312,5.1445312 v 72 c 0,2.824372 2.3201592,5.144531 5.1445312,5.144531 h 52 c 2.824372,0 5.144531,-2.320159 5.144531,-5.144531 V 23.699219 a 1.1447968,1.1447968 0 0 0 -0.01563,-0.1875 C 70.977847,22.605363 70.406495,21.99048 70.007812,21.591797 L 48.208984,-0.20898438 C 47.606104,-0.81186474 46.804652,-1.1445313 46,-1.1445312 Z m 1.144531,6.2890624 H 42.855469 V 24 c 0,1.724372 1.420159,3.144531 3.144531,3.144531 H 64.855469 V 74.855469 H 15.144531 Z m 34,4.4179688 L 60.4375,20.855469 H 49.144531 Z"/>
|
||||
</g>
|
||||
<g style="fill:#D8DFEE;stroke-width:0">
|
||||
<path d="M 3.0307167,13.993174 V 7.0307167 h 2.7576792 2.7576792 v 1.8826151 c 0,1.2578262 0.0099,1.9287572 0.029818,2.0216512 0.03884,0.181105 0.168631,0.348218 0.33827,0.43554 l 0.1355017,0.06975 1.9598092,0.0079 1.959809,0.0078 v 4.749829 4.749829 H 8 3.0307167 Z" transform="matrix(5,0,0,5,0,-30)" />
|
||||
<path d="M 9.8293515,9.0581469 V 7.9456453 l 1.1058025,1.1055492 c 0.608191,0.6080521 1.105802,1.1086775 1.105802,1.1125015 0,0.0038 -0.497611,0.007 -1.105802,0.007 H 9.8293515 Z" transform="matrix(5,0,0,5,0,-30)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" width="16" height="24" viewBox="0 0 80 60" id="doc" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g style="fill:#C4CFE5">
|
||||
<path d="m 14,-1.1445312 c -2.824372,0 -5.1445313,2.320159 -5.1445312,5.1445312 v 72 c 0,2.824372 2.3201592,5.144531 5.1445312,5.144531 h 52 c 2.824372,0 5.144531,-2.320159 5.144531,-5.144531 V 23.699219 a 1.1447968,1.1447968 0 0 0 -0.01563,-0.1875 C 70.977847,22.605363 70.406495,21.99048 70.007812,21.591797 L 48.208984,-0.20898438 C 47.606104,-0.81186474 46.804652,-1.1445313 46,-1.1445312 Z m 1.144531,6.2890624 H 42.855469 V 24 c 0,1.724372 1.420159,3.144531 3.144531,3.144531 H 64.855469 V 74.855469 H 15.144531 Z m 34,4.4179688 L 60.4375,20.855469 H 49.144531 Z"/>
|
||||
</g>
|
||||
<g style="fill:#4665A2;stroke-width:0">
|
||||
<path d="M 3.0307167,13.993174 V 7.0307167 h 2.7576792 2.7576792 v 1.8826151 c 0,1.2578262 0.0099,1.9287572 0.029818,2.0216512 0.03884,0.181105 0.168631,0.348218 0.33827,0.43554 l 0.1355017,0.06975 1.9598092,0.0079 1.959809,0.0078 v 4.749829 4.749829 H 8 3.0307167 Z" transform="matrix(5,0,0,5,0,-30)" />
|
||||
<path d="M 9.8293515,9.0581469 V 7.9456453 l 1.1058025,1.1055492 c 0.608191,0.6080521 1.105802,1.1086775 1.105802,1.1125015 0,0.0038 -0.497611,0.007 -1.105802,0.007 H 9.8293515 Z" transform="matrix(5,0,0,5,0,-30)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" viewBox="0 0 104 31" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="a">
|
||||
<stop stop-color="#5373B4" offset="0"/>
|
||||
<stop stop-color="#7C95C6" offset="1"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="d" x1="31.474" x2="31.474" y1="24.821" y2="26.773" gradientUnits="userSpaceOnUse" xlink:href="#a"/>
|
||||
<linearGradient id="c" x1="31.474" x2="31.474" y1="24.821" y2="26.773" gradientTransform="matrix(.6816 0 0 1.0248 72.391 -.91809)" gradientUnits="userSpaceOnUse" xlink:href="#a"/>
|
||||
<linearGradient id="b" x1="56.295" x2="56.295" y1="24.622" y2="26.574" gradientUnits="userSpaceOnUse" xlink:href="#a"/>
|
||||
<linearGradient id="e" x1="49.067" x2="48.956" y1="19.719" y2="9.5227" gradientTransform="matrix(.97968 0 0 1.0207 -.25579 -.25579)" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C0CCE3" offset="0"/>
|
||||
<stop stop-color="#EEF1F7" offset="1"/>
|
||||
</linearGradient>
|
||||
<filter id="f" x="-.010676" y="-.045304" width="1.0214" height="1.0906" color-interpolation-filters="sRGB">
|
||||
<feGaussianBlur stdDeviation="0.45293203"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<g>
|
||||
<path transform="translate(-2.5759 -27.848)" d="m13.609 32.203v6.8633h-0.05078c-0.40533-0.66867-0.96254-1.1715-1.6719-1.5059-0.69244-0.35193-1.4282-0.52734-2.2051-0.52734-0.96267 0-1.807 0.2027-2.5332 0.60742-0.72622 0.38713-1.3344 0.90556-1.8242 1.5566-0.47289 0.65108-0.83456 1.4092-1.0879 2.2715-0.23644 0.84464-0.35547 1.7236-0.35547 2.6387 0 0.95022 0.11902 1.8643 0.35547 2.7441 0.25333 0.87983 0.615 1.6633 1.0879 2.3496 0.48978 0.66867 1.1065 1.2066 1.8496 1.6113 0.74311 0.38713 1.6044 0.58008 2.584 0.58008 0.86133 0 1.6311-0.15787 2.3066-0.47461 0.69244-0.33434 1.2497-0.87227 1.6719-1.6113h0.05078v1.7422h3.4199v-18.846zm12.875 4.8301c-1.0302 0-1.9596 0.17541-2.7871 0.52734-0.82756 0.33434-1.5358 0.81965-2.127 1.4531-0.59111 0.61588-1.0483 1.3721-1.3691 2.2695-0.32089 0.87983-0.48047 1.866-0.48047 2.957s0.15958 2.0752 0.48047 2.9551c0.32089 0.87983 0.77803 1.6361 1.3691 2.2695 0.59111 0.61588 1.2994 1.0914 2.127 1.4258 0.82756 0.33434 1.7569 0.50195 2.7871 0.50195 1.0302 0 1.9596-0.16762 2.7871-0.50195 0.84444-0.33434 1.5612-0.8099 2.1523-1.4258 0.59111-0.63348 1.0483-1.3897 1.3691-2.2695 0.32089-0.87983 0.48047-1.8641 0.48047-2.9551s-0.15958-2.0772-0.48047-2.957c-0.32089-0.89743-0.77803-1.6536-1.3691-2.2695-0.59111-0.63348-1.3079-1.1188-2.1523-1.4531-0.82756-0.35193-1.7569-0.52734-2.7871-0.52734zm41.715 0c-0.912 0-1.7223 0.18516-2.4316 0.55469-0.69244 0.36953-1.2752 0.87043-1.748 1.5039-0.47289 0.61588-0.83651 1.337-1.0898 2.1641-0.23645 0.80944-0.35352 1.6553-0.35352 2.5352 0 0.93262 0.10007 1.8214 0.30273 2.666 0.21956 0.82704 0.55767 1.556 1.0137 2.1895 0.456 0.61588 1.0387 1.109 1.748 1.4785 0.70933 0.35193 1.5536 0.5293 2.5332 0.5293 0.79378 0 1.5446-0.16762 2.2539-0.50195 0.72622-0.35193 1.2834-0.88986 1.6719-1.6113h0.05078v1.7949c0.01689 0.96782-0.21071 1.7689-0.68359 2.4023-0.456 0.63348-1.1898 0.95117-2.2031 0.95117-0.64178 0-1.2075-0.14228-1.6973-0.42383-0.48978-0.26395-0.81939-0.74731-0.98828-1.4512h-3.5723c0.05067 0.77425 0.25276 1.435 0.60742 1.9805 0.37156 0.56309 0.8287 1.0192 1.3691 1.3711 0.55733 0.35193 1.1656 0.60726 1.8242 0.76562 0.67556 0.17597 1.3328 0.26562 1.9746 0.26562 1.5031 0 2.7025-0.21245 3.5977-0.63477 0.89511-0.42232 1.5798-0.94076 2.0527-1.5566 0.47289-0.59829 0.777-1.2493 0.91211-1.9531 0.152-0.70386 0.22656-1.3295 0.22656-1.875v-12.775h-3.4199v1.8223h-0.05078c-0.43911-0.79185-0.98782-1.3551-1.6465-1.6895-0.64178-0.33434-1.3926-0.50195-2.2539-0.50195zm16.523 0c-0.99644 0-1.9088 0.18516-2.7363 0.55469-0.81067 0.36953-1.5124 0.88018-2.1035 1.5312-0.59111 0.63348-1.0463 1.3897-1.3672 2.2695s-0.48047 1.831-0.48047 2.8516c0 1.0558 0.15108 2.0225 0.45508 2.9023 0.32089 0.87983 0.76758 1.6361 1.3418 2.2695 0.57422 0.63348 1.276 1.1266 2.1035 1.4785 0.82756 0.33434 1.7569 0.50195 2.7871 0.50195 1.4862 0 2.7517-0.35277 3.7988-1.0566 1.0471-0.70387 1.8254-1.8733 2.332-3.5098h-3.168c-0.11822 0.42232-0.43934 0.82772-0.96289 1.2148-0.52355 0.36953-1.1468 0.55274-1.873 0.55273-1.0133 0-1.7916-0.27286-2.332-0.81836-0.54044-0.5455-0.83605-1.4245-0.88672-2.6387h9.4492c0.06756-1.0558-0.01551-2.0673-0.25195-3.0352-0.23644-0.96782-0.62557-1.8293-1.166-2.5859-0.52356-0.75666-1.1998-1.355-2.0273-1.7949-0.82756-0.45751-1.7974-0.6875-2.9121-0.6875zm16.189 0c-0.76 0-1.5023 0.18516-2.2285 0.55469-0.72622 0.35193-1.3174 0.92299-1.7734 1.7148h-0.07617v-1.9004h-3.4199v13.646h3.5977v-7.1523c0-1.3901 0.21909-2.3841 0.6582-2.9824 0.43911-0.61588 1.1494-0.92383 2.1289-0.92383 0.86133 0 1.4611 0.28066 1.7988 0.84375 0.33777 0.5455 0.50586 1.3816 0.50586 2.5078v7.707h3.5976v-8.3926c0-0.84464-0.0765-1.6106-0.22851-2.2969-0.13511-0.70387-0.37971-1.2925-0.73438-1.7676-0.35466-0.49271-0.84386-0.87277-1.4688-1.1367-0.608-0.28155-1.3948-0.42188-2.3574-0.42188zm-66.063 0.36914 4.3066 6.4668-4.7129 7.1797h4.0293l2.7363-4.3027 2.7344 4.3027h4.1055l-4.8398-7.2578 4.3066-6.3887h-3.9766l-2.2793 3.5645-2.3066-3.5645zm13.275 0 4.584 12.803c0.10133 0.26395 0.15234 0.54461 0.15234 0.84375 0 0.40472-0.11707 0.77504-0.35352 1.1094-0.21956 0.33434-0.56617 0.52729-1.0391 0.58008-0.35467 0.0176-0.70979 0.0098-1.0645-0.02539-0.35467-0.03519-0.70128-0.07028-1.0391-0.10547v3.0879c0.37156 0.03519 0.73518 0.06051 1.0898 0.07813 0.37156 0.03519 0.74368 0.05273 1.1152 0.05273 1.2329 0 2.1943-0.23778 2.8867-0.71289 0.69244-0.47511 1.2326-1.2664 1.6211-2.375l5.4727-15.336h-3.7246l-2.8613 9.3438h-0.05078l-2.9648-9.3438zm-37.48 2.4551c0.59111 0 1.0823 0.12279 1.4707 0.36914 0.38844 0.24635 0.6991 0.57184 0.93555 0.97656 0.25333 0.38713 0.43187 0.84515 0.5332 1.373 0.10133 0.5103 0.15234 1.0482 0.15234 1.6113 0 0.56309-0.05101 1.1069-0.15234 1.6348-0.10133 0.5279-0.27137 1.0035-0.50781 1.4258-0.23644 0.40472-0.5556 0.73021-0.96094 0.97656-0.38844 0.24635-0.87959 0.36914-1.4707 0.36914-0.55733 0-1.038-0.12279-1.4434-0.36914-0.38844-0.26395-0.71806-0.59723-0.98828-1.002-0.25333-0.42232-0.43842-0.89788-0.55664-1.4258s-0.17773-1.0561-0.17773-1.584c-1e-7 -0.56309 0.05101-1.0991 0.15234-1.6094 0.11822-0.5279 0.29481-0.99567 0.53125-1.400Line truncated
|
||||
<path d="m0.97202 24.161 43.605-0.0019 0.0508 3.3061-43.6 0.04174z" fill="url(#d)" stroke="#000" stroke-width=".5"/>
|
||||
<path d="m10.283 3.5547v6.8633h-0.05078c-0.40533-0.66867-0.96254-1.1715-1.6719-1.5059-0.69244-0.35193-1.4282-0.52734-2.2051-0.52734-0.96267 0-1.807 0.2027-2.5332 0.60742-0.72622 0.38713-1.3344 0.90556-1.8242 1.5566-0.47289 0.65108-0.83456 1.4092-1.0879 2.2715-0.23644 0.84464-0.35547 1.7236-0.35547 2.6387 0 0.95022 0.11902 1.8643 0.35547 2.7441 0.25333 0.87983 0.615 1.6633 1.0879 2.3496 0.48978 0.66867 1.1065 1.2066 1.8496 1.6113 0.74311 0.38713 1.6044 0.58008 2.584 0.58008 0.86133 0 1.6311-0.15787 2.3066-0.47461 0.69244-0.33434 1.2497-0.87227 1.6719-1.6113h0.05078v1.7422h3.4199v-18.846zm12.875 4.8301c-1.0302 0-1.9596 0.17541-2.7871 0.52734-0.82756 0.33434-1.5358 0.81965-2.127 1.4531-0.59111 0.61588-1.0483 1.3721-1.3691 2.2695-0.32089 0.87983-0.48047 1.866-0.48047 2.957s0.15958 2.0752 0.48047 2.9551c0.32089 0.87983 0.77803 1.6361 1.3691 2.2695 0.59111 0.61588 1.2994 1.0914 2.127 1.4258 0.82756 0.33434 1.7569 0.50195 2.7871 0.50195 1.0302 0 1.9596-0.16762 2.7871-0.50195 0.84444-0.33434 1.5612-0.8099 2.1523-1.4258 0.59111-0.63348 1.0483-1.3897 1.3691-2.2695 0.32089-0.87983 0.48047-1.8641 0.48047-2.9551s-0.15958-2.0772-0.48047-2.957c-0.32089-0.89743-0.77803-1.6536-1.3691-2.2695-0.59111-0.63348-1.3079-1.1188-2.1523-1.4531-0.82756-0.35193-1.7569-0.52734-2.7871-0.52734zm41.715 0c-0.912 0-1.7223 0.18516-2.4316 0.55469-0.69244 0.36953-1.2752 0.87043-1.748 1.5039-0.47289 0.61588-0.83651 1.337-1.0898 2.1641-0.23644 0.80944-0.35352 1.6553-0.35352 2.5352 0 0.93262 0.10007 1.8214 0.30273 2.666 0.21956 0.82704 0.55767 1.556 1.0137 2.1895 0.456 0.61588 1.0387 1.109 1.748 1.4785 0.70933 0.35193 1.5536 0.5293 2.5332 0.5293 0.79378 0 1.5446-0.16762 2.2539-0.50195 0.72622-0.35193 1.2834-0.88986 1.6719-1.6113h0.05078v1.7949c0.01689 0.96782-0.21071 1.7689-0.68359 2.4023-0.456 0.63348-1.1898 0.95117-2.2031 0.95117-0.64178 0-1.2075-0.14228-1.6973-0.42383-0.48978-0.26395-0.81939-0.74731-0.98828-1.4512h-3.5723c0.05067 0.77425 0.25276 1.435 0.60742 1.9805 0.37156 0.56309 0.8287 1.0192 1.3691 1.3711 0.55733 0.35193 1.1656 0.60726 1.8242 0.76562 0.67556 0.17597 1.3328 0.26562 1.9746 0.26562 1.5031 0 2.7025-0.21245 3.5977-0.63477 0.89511-0.42232 1.5798-0.94076 2.0527-1.5566 0.47289-0.59829 0.777-1.2493 0.91211-1.9531 0.152-0.70386 0.22656-1.3295 0.22656-1.875v-12.775h-3.4199v1.8223h-0.05078c-0.43911-0.79185-0.98782-1.3551-1.6465-1.6895-0.64178-0.33434-1.3926-0.50195-2.2539-0.50195zm16.523 0c-0.99644 0-1.9088 0.18516-2.7363 0.55469-0.81067 0.36953-1.5124 0.88017-2.1035 1.5312-0.59111 0.63348-1.0463 1.3897-1.3672 2.2695s-0.48047 1.831-0.48047 2.8516c0 1.0558 0.15108 2.0225 0.45508 2.9023 0.32089 0.87983 0.76758 1.6361 1.3418 2.2695 0.57422 0.63348 1.276 1.1266 2.1035 1.4785 0.82756 0.33434 1.7569 0.50195 2.7871 0.50195 1.4862 0 2.7517-0.35278 3.7988-1.0566 1.0471-0.70386 1.8254-1.8733 2.332-3.5098h-3.168c-0.11822 0.42232-0.43934 0.82772-0.96289 1.2148-0.52355 0.36953-1.1468 0.55274-1.873 0.55273-1.0133 0-1.7916-0.27286-2.332-0.81836-0.54044-0.5455-0.83605-1.4245-0.88672-2.6387h9.4492c0.06756-1.0558-0.01551-2.0673-0.25195-3.0352-0.23644-0.96782-0.62557-1.8293-1.166-2.5859-0.52356-0.75666-1.1998-1.355-2.0273-1.7949-0.82756-0.45751-1.7974-0.6875-2.9121-0.6875zm16.189 0c-0.76 0-1.5023 0.18516-2.2285 0.55469-0.72622 0.35193-1.3174 0.923-1.7734 1.7148h-0.07617v-1.9004h-3.4199v13.646h3.5977v-7.1523c0-1.3901 0.21909-2.3841 0.6582-2.9824 0.43911-0.61588 1.1494-0.92383 2.1289-0.92383 0.86133 0 1.461 0.28066 1.7988 0.84375 0.33778 0.5455 0.50586 1.3816 0.50586 2.5078v7.707h3.5977v-8.3926c0-0.84464-0.0765-1.6106-0.22852-2.2969-0.13511-0.70387-0.3797-1.2925-0.73437-1.7676-0.35466-0.49271-0.84386-0.87277-1.4688-1.1367-0.608-0.28155-1.3948-0.42188-2.3574-0.42188zm-66.062 0.36914 4.3066 6.4668-4.7129 7.1797h4.0293l2.7363-4.3027 2.7344 4.3027h4.1055l-4.8398-7.2578 4.3066-6.3887h-3.9766l-2.2793 3.5645-2.3066-3.5645zm13.275 0 4.584 12.803c0.10133 0.26395 0.15234 0.54461 0.15234 0.84375 0 0.40472-0.11707 0.77504-0.35352 1.1094-0.21956 0.33434-0.56617 0.52729-1.0391 0.58008-0.35467 0.0176-0.70979 0.0098-1.0645-0.02539-0.35467-0.03519-0.70128-0.07027-1.0391-0.10547v3.0879c0.37156 0.03519 0.73518 0.06052 1.0898 0.07813 0.37156 0.03519 0.74368 0.05273 1.1152 0.05273 1.2329 0 2.1943-0.23778 2.8867-0.71289 0.69244-0.47511 1.2326-1.2664 1.6211-2.375l5.4727-15.336h-3.7246l-2.8613 9.3437h-0.05078l-2.9648-9.3437zm-37.48 2.4551c0.59111 0 1.0823 0.12279 1.4707 0.36914s0.6991 0.57184 0.93555 0.97656c0.25333 0.38713 0.43187 0.84515 0.5332 1.373 0.10133 0.5103 0.15234 1.0482 0.15234 1.6113 0 0.56309-0.05101 1.1069-0.15234 1.6348-0.10133 0.5279-0.27137 1.0035-0.50781 1.4258-0.23644 0.40472-0.5556 0.73021-0.96094 0.97656-0.38844 0.24635-0.87959 0.36914-1.4707 0.36914-0.55733 0-1.038-0.12279-1.4434-0.36914-0.38844-0.26395-0.71806-0.59723-0.98828-1.002-0.25333-0.42232-0.43842-0.89788-0.55664-1.4258s-0.17773-1.0561-0.17773-1.584c-1e-7 -0.56309 0.05101-1.0991 0.15234-1.6094 0.11822-0.5279 0.29481-0.99567 0.53125-1.4004 0.25333-0.40472 0.58295-0.73021 0.98828-0.97656 0.40533-0Line truncated
|
||||
<path d="m52.988 27.291c0.99602-1.0359 1.3944-1.8725 1.7928-3.1076l3.8247-0.03984c0.3113 1.6096 0.82413 2.5137 1.6335 3.1474z" fill="url(#b)" stroke="#000" stroke-width=".5"/>
|
||||
<path d="m73.89 24.04 28.885-0.2011-0.12476 3.3879-31.033 0.16229c1.2621-1.0234 1.9665-2.2859 2.2724-3.3491z" fill="url(#c)" stroke="#000" stroke-width=".41788"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
@licstart The following is the entire license notice for the JavaScript code in this file.
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 1997-2020 by Dimitri van Heesch
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@licend The above is the entire license notice for the JavaScript code in this file
|
||||
*/
|
||||
function toggleVisibility(linkObj)
|
||||
{
|
||||
var base = $(linkObj).attr('id');
|
||||
var summary = $('#'+base+'-summary');
|
||||
var content = $('#'+base+'-content');
|
||||
var trigger = $('#'+base+'-trigger');
|
||||
var src=$(trigger).attr('src');
|
||||
if (content.is(':visible')===true) {
|
||||
content.hide();
|
||||
summary.show();
|
||||
$(linkObj).addClass('closed').removeClass('opened');
|
||||
$(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
|
||||
} else {
|
||||
content.show();
|
||||
summary.hide();
|
||||
$(linkObj).removeClass('closed').addClass('opened');
|
||||
$(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateStripes()
|
||||
{
|
||||
$('table.directory tr').
|
||||
removeClass('even').filter(':visible:even').addClass('even');
|
||||
$('table.directory tr').
|
||||
removeClass('odd').filter(':visible:odd').addClass('odd');
|
||||
}
|
||||
|
||||
function toggleLevel(level)
|
||||
{
|
||||
$('table.directory tr').each(function() {
|
||||
var l = this.id.split('_').length-1;
|
||||
var i = $('#img'+this.id.substring(3));
|
||||
var a = $('#arr'+this.id.substring(3));
|
||||
if (l<level+1) {
|
||||
i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
|
||||
a.html('▼');
|
||||
$(this).show();
|
||||
} else if (l==level+1) {
|
||||
i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
|
||||
a.html('►');
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
updateStripes();
|
||||
}
|
||||
|
||||
function toggleFolder(id)
|
||||
{
|
||||
// the clicked row
|
||||
var currentRow = $('#row_'+id);
|
||||
|
||||
// all rows after the clicked row
|
||||
var rows = currentRow.nextAll("tr");
|
||||
|
||||
var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
|
||||
|
||||
// only match elements AFTER this one (can't hide elements before)
|
||||
var childRows = rows.filter(function() { return this.id.match(re); });
|
||||
|
||||
// first row is visible we are HIDING
|
||||
if (childRows.filter(':first').is(':visible')===true) {
|
||||
// replace down arrow by right arrow for current row
|
||||
var currentRowSpans = currentRow.find("span");
|
||||
currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
|
||||
currentRowSpans.filter(".arrow").html('►');
|
||||
rows.filter("[id^=row_"+id+"]").hide(); // hide all children
|
||||
} else { // we are SHOWING
|
||||
// replace right arrow by down arrow for current row
|
||||
var currentRowSpans = currentRow.find("span");
|
||||
currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
|
||||
currentRowSpans.filter(".arrow").html('▼');
|
||||
// replace down arrows by right arrows for child rows
|
||||
var childRowsSpans = childRows.find("span");
|
||||
childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
|
||||
childRowsSpans.filter(".arrow").html('►');
|
||||
childRows.show(); //show all children
|
||||
}
|
||||
updateStripes();
|
||||
}
|
||||
|
||||
|
||||
function toggleInherit(id)
|
||||
{
|
||||
var rows = $('tr.inherit.'+id);
|
||||
var img = $('tr.inherit_header.'+id+' img');
|
||||
var src = $(img).attr('src');
|
||||
if (rows.filter(':first').is(':visible')===true) {
|
||||
rows.css('display','none');
|
||||
$(img).attr('src',src.substring(0,src.length-8)+'closed.png');
|
||||
} else {
|
||||
rows.css('display','table-row'); // using show() causes jump in firefox
|
||||
$(img).attr('src',src.substring(0,src.length-10)+'open.png');
|
||||
}
|
||||
}
|
||||
|
||||
var opened=true;
|
||||
// in case HTML_COLORSTYLE is LIGHT or DARK the vars will be replaced, so we write them out explicitly and use double quotes
|
||||
var plusImg = [ "var(--fold-plus-image)", "var(--fold-plus-image-relpath)" ];
|
||||
var minusImg = [ "var(--fold-minus-image)", "var(--fold-minus-image-relpath)" ];
|
||||
|
||||
// toggle all folding blocks
|
||||
function codefold_toggle_all(relPath) {
|
||||
if (opened) {
|
||||
$('#fold_all').css('background-image',plusImg[relPath]);
|
||||
$('div[id^=foldopen]').hide();
|
||||
$('div[id^=foldclosed]').show();
|
||||
} else {
|
||||
$('#fold_all').css('background-image',minusImg[relPath]);
|
||||
$('div[id^=foldopen]').show();
|
||||
$('div[id^=foldclosed]').hide();
|
||||
}
|
||||
opened=!opened;
|
||||
}
|
||||
|
||||
// toggle single folding block
|
||||
function codefold_toggle(id) {
|
||||
$('#foldopen'+id).toggle();
|
||||
$('#foldclosed'+id).toggle();
|
||||
}
|
||||
function init_codefold(relPath) {
|
||||
$('span[class=lineno]').css(
|
||||
{'padding-right':'4px',
|
||||
'margin-right':'2px',
|
||||
'display':'inline-block',
|
||||
'width':'54px',
|
||||
'background':'linear-gradient(var(--fold-line-color),var(--fold-line-color)) no-repeat 46px/2px 100%'
|
||||
});
|
||||
// add global toggle to first line
|
||||
$('span[class=lineno]:first').append('<span class="fold" id="fold_all" '+
|
||||
'onclick="javascript:codefold_toggle_all('+relPath+');" '+
|
||||
'style="background-image:'+minusImg[relPath]+';"></span>');
|
||||
// add vertical lines to other rows
|
||||
$('span[class=lineno]').not(':eq(0)').append('<span class="fold"></span>');
|
||||
// add toggle controls to lines with fold divs
|
||||
$('div[class=foldopen]').each(function() {
|
||||
// extract specific id to use
|
||||
var id = $(this).attr('id').replace('foldopen','');
|
||||
// extract start and end foldable fragment attributes
|
||||
var start = $(this).attr('data-start');
|
||||
var end = $(this).attr('data-end');
|
||||
// replace normal fold span with controls for the first line of a foldable fragment
|
||||
$(this).find('span[class=fold]:first').replaceWith('<span class="fold" '+
|
||||
'onclick="javascript:codefold_toggle(\''+id+'\');" '+
|
||||
'style="background-image:'+minusImg[relPath]+';"></span>');
|
||||
// append div for folded (closed) representation
|
||||
$(this).after('<div id="foldclosed'+id+'" class="foldclosed" style="display:none;"></div>');
|
||||
// extract the first line from the "open" section to represent closed content
|
||||
var line = $(this).children().first().clone();
|
||||
// remove any glow that might still be active on the original line
|
||||
$(line).removeClass('glow');
|
||||
if (start) {
|
||||
// if line already ends with a start marker (e.g. trailing {), remove it
|
||||
$(line).html($(line).html().replace(new RegExp('\\s*'+start+'\\s*$','g'),''));
|
||||
}
|
||||
// replace minus with plus symbol
|
||||
$(line).find('span[class=fold]').css('background-image',plusImg[relPath]);
|
||||
// append ellipsis
|
||||
$(line).append(' '+start+'<a href="javascript:codefold_toggle(\''+id+'\')">…</a>'+end);
|
||||
// insert constructed line into closed div
|
||||
$('#foldclosed'+id).html(line);
|
||||
});
|
||||
}
|
||||
|
||||
/* @license-end */
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" width="16" height="24" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g style="fill:#4665A2;">
|
||||
<path d="M1,5.998l-0,16.002c-0,1.326 0.527,2.598 1.464,3.536c0.938,0.937 2.21,1.464 3.536,1.464c5.322,0 14.678,-0 20,0c1.326,0 2.598,-0.527 3.536,-1.464c0.937,-0.938 1.464,-2.21 1.464,-3.536c0,-3.486 0,-8.514 0,-12c0,-1.326 -0.527,-2.598 -1.464,-3.536c-0.938,-0.937 -2.21,-1.464 -3.536,-1.464c-0,0 -10.586,0 -10.586,0c0,-0 -3.707,-3.707 -3.707,-3.707c-0.187,-0.188 -0.442,-0.293 -0.707,-0.293l-5.002,0c-2.76,0 -4.998,2.238 -4.998,4.998Zm2,-0l-0,16.002c-0,0.796 0.316,1.559 0.879,2.121c0.562,0.563 1.325,0.879 2.121,0.879l20,0c0.796,0 1.559,-0.316 2.121,-0.879c0.563,-0.562 0.879,-1.325 0.879,-2.121c0,-3.486 0,-8.514 0,-12c0,-0.796 -0.316,-1.559 -0.879,-2.121c-0.562,-0.563 -1.325,-0.879 -2.121,-0.879c-7.738,0 -11,0 -11,0c-0.265,0 -0.52,-0.105 -0.707,-0.293c-0,0 -3.707,-3.707 -3.707,-3.707c-0,0 -4.588,0 -4.588,0c-1.656,0 -2.998,1.342 -2.998,2.998Z"/>
|
||||
</g>
|
||||
<g style="fill:#D8DFEE;stroke-width:0;">
|
||||
<path d="M 5.6063709,24.951908 C 4.3924646,24.775461 3.4197129,23.899792 3.1031586,22.698521 L 3.0216155,22.389078 V 13.997725 5.6063709 L 3.1037477,5.2982247 C 3.3956682,4.2029881 4.1802788,3.412126 5.2787258,3.105917 5.5646428,3.0262132 5.6154982,3.0244963 8.0611641,3.0119829 l 2.4911989,-0.012746 1.932009,1.9300342 c 1.344142,1.3427669 1.976319,1.9498819 2.07763,1.9952626 0.137456,0.061571 0.474218,0.066269 6.006826,0.083795 l 5.861206,0.018568 0.29124,0.081916 c 1.094895,0.3079569 1.890116,1.109428 2.175567,2.192667 l 0.08154,0.3094425 V 16 22.389078 l -0.08154,0.309443 c -0.28446,1.079482 -1.086411,1.888085 -2.175567,2.193614 l -0.29124,0.0817 -10.302616,0.0049 c -5.700217,0.0027 -10.4001945,-0.0093 -10.5210471,-0.02684 z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" width="16" height="24" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g style="fill:#C4CFE5;">
|
||||
<path d="M1,5.998l-0,16.002c-0,1.326 0.527,2.598 1.464,3.536c0.938,0.937 2.21,1.464 3.536,1.464c5.322,0 14.678,-0 20,0c1.326,0 2.598,-0.527 3.536,-1.464c0.937,-0.938 1.464,-2.21 1.464,-3.536c0,-3.486 0,-8.514 0,-12c0,-1.326 -0.527,-2.598 -1.464,-3.536c-0.938,-0.937 -2.21,-1.464 -3.536,-1.464c-0,0 -10.586,0 -10.586,0c0,-0 -3.707,-3.707 -3.707,-3.707c-0.187,-0.188 -0.442,-0.293 -0.707,-0.293l-5.002,0c-2.76,0 -4.998,2.238 -4.998,4.998Zm2,-0l-0,16.002c-0,0.796 0.316,1.559 0.879,2.121c0.562,0.563 1.325,0.879 2.121,0.879l20,0c0.796,0 1.559,-0.316 2.121,-0.879c0.563,-0.562 0.879,-1.325 0.879,-2.121c0,-3.486 0,-8.514 0,-12c0,-0.796 -0.316,-1.559 -0.879,-2.121c-0.562,-0.563 -1.325,-0.879 -2.121,-0.879c-7.738,0 -11,0 -11,0c-0.265,0 -0.52,-0.105 -0.707,-0.293c-0,0 -3.707,-3.707 -3.707,-3.707c-0,0 -4.588,0 -4.588,0c-1.656,0 -2.998,1.342 -2.998,2.998Z"/>
|
||||
</g>
|
||||
<g style="fill:#4665A2;stroke-width:0;">
|
||||
<path d="M 5.6063709,24.951908 C 4.3924646,24.775461 3.4197129,23.899792 3.1031586,22.698521 L 3.0216155,22.389078 V 13.997725 5.6063709 L 3.1037477,5.2982247 C 3.3956682,4.2029881 4.1802788,3.412126 5.2787258,3.105917 5.5646428,3.0262132 5.6154982,3.0244963 8.0611641,3.0119829 l 2.4911989,-0.012746 1.932009,1.9300342 c 1.344142,1.3427669 1.976319,1.9498819 2.07763,1.9952626 0.137456,0.061571 0.474218,0.066269 6.006826,0.083795 l 5.861206,0.018568 0.29124,0.081916 c 1.094895,0.3079569 1.890116,1.109428 2.175567,2.192667 l 0.08154,0.3094425 V 16 22.389078 l -0.08154,0.309443 c -0.28446,1.079482 -1.086411,1.888085 -2.175567,2.193614 l -0.29124,0.0817 -10.302616,0.0049 c -5.700217,0.0027 -10.4001945,-0.0093 -10.5210471,-0.02684 z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" width="16" height="24" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g style="fill:#4665A2;">
|
||||
<path
|
||||
d="M1,5.998l0,16.002c-0,1.326 0.527,2.598 1.464,3.536c0.938,0.937 2.21,1.464 3.536,1.464c5.322,0 14.678,-0 20,0c1.326,0 2.598,-0.527 3.536,-1.464c0.937,-0.938 1.464,-2.21 1.464,-3.536c0,-3.486 0,-8.514 0,-12c0,-1.326 -0.527,-2.598 -1.464,-3.536c-0.938,-0.937 -2.21,-1.464 -3.536,-1.464c-0,0 -10.586,0 -10.586,0c0,-0 -3.707,-3.707 -3.707,-3.707c-0.187,-0.188 -0.442,-0.293 -0.707,-0.293l-5.002,0c-2.76,0 -4.998,2.238 -4.998,4.998Zm28,14.415l-3.456,-5.925c-0.538,-0.921 -1.524,-1.488 -2.591,-1.488c-0,0 -12.905,0 -12.906,0c-1.067,0 -2.053,0.567 -2.591,1.488l-4.453,7.635c0.03,0.751 0.342,1.465 0.876,1.998c0.562,0.563 1.325,0.879 2.121,0.879l20,0c0.796,0 1.559,-0.316 2.121,-0.879c0.563,-0.562 0.879,-1.325 0.879,-2.121l0,-1.587Zm0,-3.969l0,-6.444c0,-0.796 -0.316,-1.559 -0.879,-2.121c-0.562,-0.563 -1.325,-0.879 -2.121,-0.879c-7.738,0 -11,0 -11,0c-0.265,0 -0.52,-0.105 -0.707,-0.293c-0,0 -3.707,-3.707 -3.707,-3.707c-0,0 -4.588,0 -4.588,0c-1.656,0 -2.998,1.342 -2.998,2.998l0,12.16l2.729,-4.677c0.896,-1.536 2.54,-2.481 4.318,-2.481c3.354,0 9.552,0 12.906,0c1.778,0 3.422,0.945 4.318,2.481l1.729,2.963Z"
|
||||
id="path2" />
|
||||
</g>
|
||||
<g style="fill:#D8DFEE;stroke-width:0;">
|
||||
<path
|
||||
d="M 5.3879408,24.913408 C 4.1598821,24.650818 3.1571088,23.558656 3.053503,22.370876 L 3.0312746,22.116041 5.2606813,18.293515 C 6.486855,16.191126 7.5598351,14.372696 7.6450818,14.25256 8.0043056,13.746312 8.5423079,13.363007 9.2104664,13.137285 l 0.2548351,-0.08609 6.9294785,-0.0097 c 6.805096,-0.0095 6.934944,-0.0084 7.234011,0.06267 0.695577,0.165199 1.290483,0.557253 1.714887,1.130141 0.08158,0.110125 0.938747,1.556711 1.90481,3.214634 l 1.756479,3.014406 -0.0186,0.971942 c -0.01387,0.724723 -0.03365,1.032131 -0.07778,1.208575 -0.242792,0.970733 -0.88732,1.735415 -1.772382,2.102793 -0.58835,0.244217 0.247209,0.227436 -11.161974,0.224159 -9.0281537,-0.0026 -10.3636023,-0.0098 -10.5862902,-0.05746 z"
|
||||
id="path199" /><path
|
||||
d="M 3.0126385,11.849829 3.0235061,5.5881684 3.1020974,5.2969283 C 3.3478146,4.3863605 3.93576,3.6757372 4.756668,3.2971229 5.3293315,3.0330025 5.1813272,3.0450949 8.0130385,3.0310668 l 2.5522875,-0.012644 1.918693,1.9107086 c 1.404146,1.3983023 1.964459,1.9332518 2.089351,1.9947704 l 0.170657,0.084062 5.897611,0.019367 c 5.553257,0.018236 5.910365,0.023213 6.116041,0.085231 1.102257,0.3323708 1.857042,1.1184422 2.154229,2.2435244 0.05645,0.2137228 0.06373,0.5643981 0.07519,3.6220748 0.0076,2.032169 -5.42e-4,3.370979 -0.02041,3.349261 -0.0182,-0.0199 -0.414296,-0.691472 -0.880217,-1.492382 -0.46592,-0.80091 -0.93093,-1.577954 -1.033354,-1.726764 -0.735716,-1.0689 -1.983568,-1.844244 -3.315972,-2.060353 -0.280375,-0.04548 -1.345158,-0.05334 -7.238708,-0.05347 -4.713933,-1.09e-4 -6.9931825,0.01221 -7.1717862,0.03874 -1.3002273,0.193134 -2.4770512,0.889916 -3.283628,1.944192 -0.1076466,0.140705 -0.8359664,1.353438 -1.6184885,2.694963 L 3.0017709,18.11149 Z"
|
||||
id="path201" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" width="16" height="24" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g style="fill:#C4CFE5;">
|
||||
<path d="M1,5.998l0,16.002c-0,1.326 0.527,2.598 1.464,3.536c0.938,0.937 2.21,1.464 3.536,1.464c5.322,0 14.678,-0 20,0c1.326,0 2.598,-0.527 3.536,-1.464c0.937,-0.938 1.464,-2.21 1.464,-3.536c0,-3.486 0,-8.514 0,-12c0,-1.326 -0.527,-2.598 -1.464,-3.536c-0.938,-0.937 -2.21,-1.464 -3.536,-1.464c-0,0 -10.586,0 -10.586,0c0,-0 -3.707,-3.707 -3.707,-3.707c-0.187,-0.188 -0.442,-0.293 -0.707,-0.293l-5.002,0c-2.76,0 -4.998,2.238 -4.998,4.998Zm28,14.415l-3.456,-5.925c-0.538,-0.921 -1.524,-1.488 -2.591,-1.488c-0,0 -12.905,0 -12.906,0c-1.067,0 -2.053,0.567 -2.591,1.488l-4.453,7.635c0.03,0.751 0.342,1.465 0.876,1.998c0.562,0.563 1.325,0.879 2.121,0.879l20,0c0.796,0 1.559,-0.316 2.121,-0.879c0.563,-0.562 0.879,-1.325 0.879,-2.121l0,-1.587Zm0,-3.969l0,-6.444c0,-0.796 -0.316,-1.559 -0.879,-2.121c-0.562,-0.563 -1.325,-0.879 -2.121,-0.879c-7.738,0 -11,0 -11,0c-0.265,0 -0.52,-0.105 -0.707,-0.293c-0,0 -3.707,-3.707 -3.707,-3.707c-0,0 -4.588,0 -4.588,0c-1.656,0 -2.998,1.342 -2.998,2.998l0,12.16l2.729,-4.677c0.896,-1.536 2.54,-2.481 4.318,-2.481c3.354,0 9.552,0 12.906,0c1.778,0 3.422,0.945 4.318,2.481l1.729,2.963Z"/>
|
||||
</g>
|
||||
<g style="fill:#4665A2;stroke-width:0;">
|
||||
<path d="M 5.3879408,24.913408 C 4.1598821,24.650818 3.1571088,23.558656 3.053503,22.370876 L 3.0312746,22.116041 5.2606813,18.293515 C 6.486855,16.191126 7.5598351,14.372696 7.6450818,14.25256 8.0043056,13.746312 8.5423079,13.363007 9.2104664,13.137285 l 0.2548351,-0.08609 6.9294785,-0.0097 c 6.805096,-0.0095 6.934944,-0.0084 7.234011,0.06267 0.695577,0.165199 1.290483,0.557253 1.714887,1.130141 0.08158,0.110125 0.938747,1.556711 1.90481,3.214634 l 1.756479,3.014406 -0.0186,0.971942 c -0.01387,0.724723 -0.03365,1.032131 -0.07778,1.208575 -0.242792,0.970733 -0.88732,1.735415 -1.772382,2.102793 -0.58835,0.244217 0.247209,0.227436 -11.161974,0.224159 -9.0281537,-0.0026 -10.3636023,-0.0098 -10.5862902,-0.05746 z" />
|
||||
<path d="M 3.0126385,11.849829 3.0235061,5.5881684 3.1020974,5.2969283 C 3.3478146,4.3863605 3.93576,3.6757372 4.756668,3.2971229 5.3293315,3.0330025 5.1813272,3.0450949 8.0130385,3.0310668 l 2.5522875,-0.012644 1.918693,1.9107086 c 1.404146,1.3983023 1.964459,1.9332518 2.089351,1.9947704 l 0.170657,0.084062 5.897611,0.019367 c 5.553257,0.018236 5.910365,0.023213 6.116041,0.085231 1.102257,0.3323708 1.857042,1.1184422 2.154229,2.2435244 0.05645,0.2137228 0.06373,0.5643981 0.07519,3.6220748 0.0076,2.032169 -5.42e-4,3.370979 -0.02041,3.349261 -0.0182,-0.0199 -0.414296,-0.691472 -0.880217,-1.492382 -0.46592,-0.80091 -0.93093,-1.577954 -1.033354,-1.726764 -0.735716,-1.0689 -1.983568,-1.844244 -3.315972,-2.060353 -0.280375,-0.04548 -1.345158,-0.05334 -7.238708,-0.05347 -4.713933,-1.09e-4 -6.9931825,0.01221 -7.1717862,0.03874 -1.3002273,0.193134 -2.4770512,0.889916 -3.283628,1.944192 -0.1076466,0.140705 -0.8359664,1.353438 -1.6184885,2.694963 L 3.0017709,18.11149 Z" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,141 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>My Project: Graph Legend</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="search/search.js"></script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectalign">
|
||||
<div id="projectname">My Project
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.8 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript" src="menudata.js"></script>
|
||||
<script type="text/javascript" src="menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() {
|
||||
initMenu('',true,false,'search.php','Search');
|
||||
$(document).ready(function() { init_search(); });
|
||||
});
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="main-nav"></div>
|
||||
</div><!-- top -->
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||||
</div>
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<div id="MSearchResults">
|
||||
<div class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div id="SRResults"></div>
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="headertitle"><div class="title">Graph Legend</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<p>This page explains how to interpret the graphs that are generated by doxygen.</p>
|
||||
<p>Consider the following example: </p><div class="fragment"><div class="line"><span class="comment">/*! Invisible class because of truncation */</span></div>
|
||||
<div class="line"><span class="keyword">class </span>Invisible { };</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/*! Truncated class, inheritance relation is hidden */</span></div>
|
||||
<div class="line"><span class="keyword">class </span>Truncated : <span class="keyword">public</span> Invisible { };</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">/* Class not documented with doxygen comments */</span></div>
|
||||
<div class="line"><span class="keyword">class </span>Undocumented { };</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/*! Class that is inherited using public inheritance */</span></div>
|
||||
<div class="line"><span class="keyword">class </span>PublicBase : <span class="keyword">public</span> Truncated { };</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/*! A template class */</span></div>
|
||||
<div class="line"><span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">class </span>Templ { };</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/*! Class that is inherited using protected inheritance */</span></div>
|
||||
<div class="line"><span class="keyword">class </span>ProtectedBase { };</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/*! Class that is inherited using private inheritance */</span></div>
|
||||
<div class="line"><span class="keyword">class </span>PrivateBase { };</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/*! Class that is used by the Inherited class */</span></div>
|
||||
<div class="line"><span class="keyword">class </span>Used { };</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/*! Super class that inherits a number of other classes */</span></div>
|
||||
<div class="line"><span class="keyword">class </span>Inherited : <span class="keyword">public</span> PublicBase,</div>
|
||||
<div class="line"> <span class="keyword">protected</span> ProtectedBase,</div>
|
||||
<div class="line"> <span class="keyword">private</span> PrivateBase,</div>
|
||||
<div class="line"> <span class="keyword">public</span> Undocumented,</div>
|
||||
<div class="line"> <span class="keyword">public</span> Templ<int></div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">private</span>:</div>
|
||||
<div class="line"> Used *m_usedClass;</div>
|
||||
<div class="line">};</div>
|
||||
</div><!-- fragment --><p> This will result in the following graph:</p>
|
||||
<center><img src="graph_legend.png" alt="" class="inline"/></center><p>The boxes in the above graph have the following meaning: </p>
|
||||
<ul>
|
||||
<li>
|
||||
A filled gray box represents the struct or class for which the graph is generated. </li>
|
||||
<li>
|
||||
A box with a black border denotes a documented struct or class. </li>
|
||||
<li>
|
||||
A box with a gray border denotes an undocumented struct or class. </li>
|
||||
<li>
|
||||
A box with a red border denotes a documented struct or class forwhich not all inheritance/containment relations are shown. A graph is truncated if it does not fit within the specified boundaries. </li>
|
||||
</ul>
|
||||
<p>The arrows have the following meaning: </p>
|
||||
<ul>
|
||||
<li>
|
||||
A blue arrow is used to visualize a public inheritance relation between two classes. </li>
|
||||
<li>
|
||||
A dark green arrow is used for protected inheritance. </li>
|
||||
<li>
|
||||
A dark red arrow is used for private inheritance. </li>
|
||||
<li>
|
||||
A purple dashed arrow is used if a class is contained or used by another class. The arrow is labelled with the variable(s) through which the pointed class or struct is accessible. </li>
|
||||
<li>
|
||||
A yellow dashed arrow denotes a relation between a template instance and the template class it was instantiated from. The arrow is labelled with the template parameters of the instance. </li>
|
||||
</ul>
|
||||
</div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
f74606a252eb303675caf37987d0b7af
|
||||
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>My Project: Main Page</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="search/search.js"></script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectalign">
|
||||
<div id="projectname">My Project
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.8 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript" src="menudata.js"></script>
|
||||
<script type="text/javascript" src="menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() {
|
||||
initMenu('',true,false,'search.php','Search');
|
||||
$(document).ready(function() { init_search(); });
|
||||
});
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="main-nav"></div>
|
||||
</div><!-- top -->
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||||
</div>
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<div id="MSearchResults">
|
||||
<div class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div id="SRResults"></div>
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="headertitle"><div class="title">My Project Documentation</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
</div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */
|
||||
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:y}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),j=function(e,t){return e===t&&(l=!0),0},D={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",B=new RegExp(M+"+","g"),$=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^Line truncated
|
||||
/*! jQuery UI - v1.13.2 - 2022-08-01
|
||||
* http://jqueryui.com
|
||||
* Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/resizable.js, widgets/mouse.js
|
||||
* Copyright jQuery Foundation and other contributors; Licensed MIT */
|
||||
|
||||
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(y){"use strict";y.ui=y.ui||{};y.ui.version="1.13.2";var n,i=0,h=Array.prototype.hasOwnProperty,a=Array.prototype.slice;y.cleanData=(n=y.cleanData,function(t){for(var e,i,s=0;null!=(i=t[s]);s++)(e=y._data(i,"events"))&&e.remove&&y(i).triggerHandler("remove");n(t)}),y.widget=function(t,i,e){var s,n,o,h={},a=t.split(".")[0],r=a+"-"+(t=t.split(".")[1]);return e||(e=i,i=y.Widget),Array.isArray(e)&&(e=y.extend.apply(null,[{}].concat(e))),y.expr.pseudos[r.toLowerCase()]=function(t){return!!y.data(t,r)},y[a]=y[a]||{},s=y[a][t],n=y[a][t]=function(t,e){if(!this||!this._createWidget)return new n(t,e);arguments.length&&this._createWidget(t,e)},y.extend(n,s,{version:e.version,_proto:y.extend({},e),_childConstructors:[]}),(o=new i).options=y.widget.extend({},o.options),y.each(e,function(e,s){function n(){return i.prototype[e].apply(this,arguments)}function o(t){return i.prototype[e].apply(this,t)}h[e]="function"==typeof s?function(){var t,e=this._super,i=this._superApply;return this._super=n,this._superApply=o,t=s.apply(this,arguments),this._super=e,this._superApply=i,t}:s}),n.prototype=y.widget.extend(o,{widgetEventPrefix:s&&o.widgetEventPrefix||t},h,{constructor:n,namespace:a,widgetName:t,widgetFullName:r}),s?(y.each(s._childConstructors,function(t,e){var i=e.prototype;y.widget(i.namespace+"."+i.widgetName,n,e._proto)}),delete s._childConstructors):i._childConstructors.push(n),y.widget.bridge(t,n),n},y.widget.extend=function(t){for(var e,i,s=a.call(arguments,1),n=0,o=s.length;n<o;n++)for(e in s[n])i=s[n][e],h.call(s[n],e)&&void 0!==i&&(y.isPlainObject(i)?t[e]=y.isPlainObject(t[e])?y.widget.extend({},t[e],i):y.widget.extend({},i):t[e]=i);return t},y.widget.bridge=function(o,e){var h=e.prototype.widgetFullName||o;y.fn[o]=function(i){var t="string"==typeof i,s=a.call(arguments,1),n=this;return t?this.length||"instance"!==i?this.each(function(){var t,e=y.data(this,h);return"instance"===i?(n=e,!1):e?"function"!=typeof e[i]||"_"===i.charAt(0)?y.error("no such method '"+i+"' for "+o+" widget instance"):(t=e[i].apply(e,s))!==e&&void 0!==t?(n=t&&t.jquery?n.pushStack(t.get()):t,!1):void 0:y.error("cannot call methods on "+o+" prior to initialization; attempted to call method '"+i+"'")}):n=void 0:(s.length&&(i=y.widget.extend.apply(null,[i].concat(s))),this.each(function(){var t=y.data(this,h);t?(t.option(i||{}),t._init&&t._init()):y.data(this,h,new e(i,this))})),n}},y.Widget=function(){},y.Widget._childConstructors=[],y.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,e){e=y(e||this.defaultElement||this)[0],this.element=y(e),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=y(),this.hoverable=y(),this.focusable=y(),this.classesElementLookup={},e!==this&&(y.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=y(e.style?e.ownerDocument:e.document||e),this.window=y(this.document[0].defaultView||this.document[0].parentWindow)),this.options=y.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:y.noop,_create:y.noop,_init:y.noop,destroy:function(){var i=this;this._destroy(),y.each(this.classesElementLookup,function(t,e){i._removeClass(e,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:y.noop,widget:function(){return this.element},option:function(t,e){var i,s,n,o=t;if(0===arguments.length)return y.widget.extend({},this.options);if("string"==typeof t)if(o={},t=(i=t.split(".")).shift(),i.length){for(s=o[t]=y.widget.extend({},this.options[t]),n=0;n<i.length-1;n++)s[i[n]]=s[i[n]]||{},s=s[i[n]];if(t=i.pop(),1===arguments.length)return void 0===s[t]?null:s[t];s[t]=e}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=e}return this._setOptions(o),this},_setOptions:function(t){for(var e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(t){var e,i,s;for(e in t)s=this.classesElementLookup[e],t[e]!==this.options.classes[e]&&s&&s.length&&(i=y(s.get()),this._removeClass(s,e),i.addClass(this._classes({element:i,keys:e,classes:t,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({diLine truncated
|
||||
* Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler
|
||||
* Licensed under MIT
|
||||
* @author Ariel Flesler
|
||||
* @version 2.1.2
|
||||
*/
|
||||
;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1<b.axis.length;u&&(d/=2);b.offset=h(b.offset);b.over=h(b.over);return this.each(function(){function k(a){var k=$.extend({},b,{queue:!0,duration:d,complete:a&&function(){a.call(q,e,b)}});r.animate(f,k)}if(null!==a){var l=n(this),q=l?this.contentWindow||window:this,r=$(q),e=a,f={},t;switch(typeof e){case "number":case "string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(e)){e= h(e);break}e=l?$(e):$(e,q);case "object":if(e.length===0)return;if(e.is||e.style)t=(e=$(e)).offset()}var v=$.isFunction(b.offset)&&b.offset(q,e)||b.offset;$.each(b.axis.split(""),function(a,c){var d="x"===c?"Left":"Top",m=d.toLowerCase(),g="scroll"+d,h=r[g](),n=p.max(q,c);t?(f[g]=t[m]+(l?0:h-r.offset()[m]),b.margin&&(f[g]-=parseInt(e.css("margin"+d),10)||0,f[g]-=parseInt(e.css("border"+d+"Width"),10)||0),f[g]+=v[m]||0,b.over[m]&&(f[g]+=e["x"===c?"width":"height"]()*b.over[m])):(d=e[m],f[g]=d.slice&& "%"===d.slice(-1)?parseFloat(d)/100*n:d);b.limit&&/^\d+$/.test(f[g])&&(f[g]=0>=f[g]?0:Math.min(f[g],n));!a&&1<b.axis.length&&(h===f[g]?f={}:u&&(k(b.onAfterFirst),f={}))});k(b.onAfter)}})};p.max=function(a,d){var b="x"===d?"Width":"Height",h="scroll"+b;if(!n(a))return a[h]-$(a)[b.toLowerCase()]();var b="client"+b,k=a.ownerDocument||a.document,l=k.documentElement,k=k.body;return Math.max(l[h],k[h])-Math.min(l[b],k[b])};$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(a){return $(a.elem)[a.prop]()}, set:function(a){var d=this.get(a);if(a.options.interrupt&&a._last&&a._last!==d)return $(a.elem).stop();var b=Math.round(a.now);d!==b&&($(a.elem)[a.prop](b),a._last=this.get(a))}};return p});
|
||||
/*!
|
||||
PowerTip v1.3.1 (2018-04-15)
|
||||
https://stevenbenner.github.io/jquery-powertip/
|
||||
Copyright (c) 2018 Steven Benner (http://stevenbenner.com/).
|
||||
Released under MIT license.
|
||||
https://raw.github.com/stevenbenner/jquery-powertip/master/LICENSE.txt
|
||||
*/
|
||||
(function(root,factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else if(typeof module==="object"&&module.exports){module.exports=factory(require("jquery"))}else{factory(root.jQuery)}})(this,function($){var $document=$(document),$window=$(window),$body=$("body");var DATA_DISPLAYCONTROLLER="displayController",DATA_HASACTIVEHOVER="hasActiveHover",DATA_FORCEDOPEN="forcedOpen",DATA_HASMOUSEMOVE="hasMouseMove",DATA_MOUSEONTOTIP="mouseOnToPopup",DATA_ORIGINALTITLE="originalTitle",DATA_POWERTIP="powertip",DATA_POWERTIPJQ="powertipjq",DATA_POWERTIPTARGET="powertiptarget",EVENT_NAMESPACE=".powertip",RAD2DEG=180/Math.PI,MOUSE_EVENTS=["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave","contextmenu"];var session={tooltips:null,isTipOpen:false,isFixedTipOpen:false,isClosing:false,tipOpenImminent:false,activeHover:null,currentX:0,currentY:0,previousX:0,previousY:0,desyncTimeout:null,closeDelayTimeout:null,mouseTrackingActive:false,delayInProgress:false,windowWidth:0,windowHeight:0,scrollTop:0,scrollLeft:0};var Collision={none:0,top:1,bottom:2,left:4,right:8};$.fn.powerTip=function(opts,arg){var targetElements=this,options,tipController;if(!targetElements.length){return targetElements}if($.type(opts)==="string"&&$.powerTip[opts]){return $.powerTip[opts].call(targetElements,targetElements,arg)}options=$.extend({},$.fn.powerTip.defaults,opts);tipController=new TooltipController(options);initTracking();targetElements.each(function elementSetup(){var $this=$(this),dataPowertip=$this.data(DATA_POWERTIP),dataElem=$this.data(DATA_POWERTIPJQ),dataTarget=$this.data(DATA_POWERTIPTARGET),title=$this.attr("title");if(!dataPowertip&&!dataTarget&&!dataElem&&title){$this.data(DATA_POWERTIP,title);$this.data(DATA_ORIGINALTITLE,title);$this.removeAttr("title")}$this.data(DATA_DISPLAYCONTROLLER,new DisplayController($this,options,tipController))});if(!options.manual){$.each(options.openEvents,function(idx,evt){if($.inArray(evt,options.closeEvents)>-1){targetElements.on(evt+EVENT_NAMESPACE,function elementToggle(event){$.powerTip.toggle(this,event)})}else{targetElements.on(evt+EVENT_NAMESPACE,function elementOpen(event){$.powerTip.show(this,event)})}});$.each(options.closeEvents,function(idx,evt){if($.inArray(evt,options.openEvents)<0){targetElements.on(evt+EVENT_NAMESPACE,function elementClose(event){$.powerTip.hide(this,!isMouseEvent(event))})}});targetElements.on("keydown"+EVENT_NAMESPACE,function elementKeyDown(event){if(event.keyCode===27){$.powerTip.hide(this,true)}})}return targetElements};$.fn.powerTip.defaults={fadeInTime:200,fadeOutTime:100,followMouse:false,popupId:"powerTip",popupClass:null,intentSensitivity:7,intentPollInterval:100,closeDelay:100,placement:"n",smartPlacement:false,offset:10,mouseOnToPopup:false,manual:false,openEvents:["mouseenter","focus"],closeEvents:["mouseleave","blur"]};$.fn.powerTip.smartPlacementLists={n:["n","ne","nw","s"],e:["e","ne","se","w","nw","sw","n","s","e"],s:["s","se","sw","n"],w:["w","nw","sw","e","ne","se","n","s","w"],nw:["nw","w","sw","n","s","se","nw"],ne:["ne","e","se","n","s","sw","ne"],sw:["sw","w","nw","s","n","ne","sw"],se:["se","e","ne","s","n","nw","se"],"nw-alt":["nw-alt","n","ne-alt","sw-alt","s","se-alt","w","e"],"ne-alt":["ne-alt","n","nw-alt","se-alt","s","sw-alt","e","w"],"sw-alt":["sw-alt","s","se-alt","nw-alt","n","ne-alt","w","e"],"se-alt":["se-alt","s","sw-alt","ne-alt","n","nw-alt","e","w"]};$.powerTip={show:function apiShowTip(element,event){if(isMouseEvent(event)){trackMouse(event);session.previousX=event.pageX;session.previousY=event.pageY;$(element).data(DATA_DISPLAYCONTROLLER).show()}else{$(element).first().data(DATA_DISPLAYCONTROLLER).show(true,true)}return element},reposition:function apiResetPosition(element){$(element).first().data(DATA_DISPLAYCONTROLLER).resetPosition();return element},hide:function apiCloseTip(element,immediate){var displayController;immediate=element?immediate:true;if(element){displayController=$(element).first().data(DATA_DISPLAYCONTROLLER)}else if(session.activeHover){displayController=session.activeHover.data(DATA_DISPLAYCONTROLLER)}if(displayController){displayController.hide(immediate)}return element},toggle:function apiToggle(element,event){if(session.activeHover&&session.activeHover.is(element)){$.powerTip.hide(element,!isMouseEvent(event))}else{$.powerTip.show(element,event)}return element}};$.powerTip.showTip=$.powerTip.show;$.powerTip.closeTip=$.powerTip.hide;function CSSCoordinates(){var me=this;me.top="auto";me.left="auto";me.right="auto";me.bottom="auto";me.set=function(property,value){if($.isNumeric(value)){me[property]=Math.round(value)}}}function DisplayController(element,options,tipController){var hoverTimer=null,myCloseDelay=null;function openTooltip(immediate,forceOpen){cancelTimer();if(!element.data(DATA_HASACTIVEHOVER)){if(!immediate){session.tipOpenImminent=true;hoverTimer=setTimeout(function intentDelay(){hoverTimer=null;checkForIntent()},oLine truncated
|
||||
* jQuery UI Touch Punch 0.2.3
|
||||
*
|
||||
* Copyright 2011–2014, Dave Furfero
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*
|
||||
* Depends:
|
||||
* jquery.ui.widget.js
|
||||
* jquery.ui.mouse.js
|
||||
*/
|
||||
!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);/*! SmartMenus jQuery Plugin - v1.1.0 - September 17, 2017
|
||||
* http://www.smartmenus.org/
|
||||
* Copyright Vasil Dinkov, Vadikom Web Ltd. http://vadikom.com; Licensed MIT */(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(require("jquery")):t(jQuery)})(function($){function initMouseDetection(t){var e=".smartmenus_mouse";if(mouseDetectionEnabled||t)mouseDetectionEnabled&&t&&($(document).off(e),mouseDetectionEnabled=!1);else{var i=!0,s=null,o={mousemove:function(t){var e={x:t.pageX,y:t.pageY,timeStamp:(new Date).getTime()};if(s){var o=Math.abs(s.x-e.x),a=Math.abs(s.y-e.y);if((o>0||a>0)&&2>=o&&2>=a&&300>=e.timeStamp-s.timeStamp&&(mouse=!0,i)){var n=$(t.target).closest("a");n.is("a")&&$.each(menuTrees,function(){return $.contains(this.$root[0],n[0])?(this.itemEnter({currentTarget:n[0]}),!1):void 0}),i=!1}}s=e}};o[touchEvents?"touchstart":"pointerover pointermove pointerout MSPointerOver MSPointerMove MSPointerOut"]=function(t){isTouchEvent(t.originalEvent)&&(mouse=!1)},$(document).on(getEventsNS(o,e)),mouseDetectionEnabled=!0}}function isTouchEvent(t){return!/^(4|mouse)$/.test(t.pointerType)}function getEventsNS(t,e){e||(e="");var i={};for(var s in t)i[s.split(" ").join(e+" ")+e]=t[s];return i}var menuTrees=[],mouse=!1,touchEvents="ontouchstart"in window,mouseDetectionEnabled=!1,requestAnimationFrame=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},cancelAnimationFrame=window.cancelAnimationFrame||function(t){clearTimeout(t)},canAnimate=!!$.fn.animate;return $.SmartMenus=function(t,e){this.$root=$(t),this.opts=e,this.rootId="",this.accessIdPrefix="",this.$subArrow=null,this.activatedItems=[],this.visibleSubMenus=[],this.showTimeout=0,this.hideTimeout=0,this.scrollTimeout=0,this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.idInc=0,this.$firstLink=null,this.$firstSub=null,this.disabled=!1,this.$disableOverlay=null,this.$touchScrollingSub=null,this.cssTransforms3d="perspective"in t.style||"webkitPerspective"in t.style,this.wasCollapsible=!1,this.init()},$.extend($.SmartMenus,{hideAll:function(){$.each(menuTrees,function(){this.menuHideAll()})},destroy:function(){for(;menuTrees.length;)menuTrees[0].destroy();initMouseDetection(!0)},prototype:{init:function(t){var e=this;if(!t){menuTrees.push(this),this.rootId=((new Date).getTime()+Math.random()+"").replace(/\D/g,""),this.accessIdPrefix="sm-"+this.rootId+"-",this.$root.hasClass("sm-rtl")&&(this.opts.rightToLeftSubMenus=!0);var i=".smartmenus";this.$root.data("smartmenus",this).attr("data-smartmenus-id",this.rootId).dataSM("level",1).on(getEventsNS({"mouseover focusin":$.proxy(this.rootOver,this),"mouseout focusout":$.proxy(this.rootOut,this),keydown:$.proxy(this.rootKeyDown,this)},i)).on(getEventsNS({mouseenter:$.proxy(this.itemEnter,this),mouseleave:$.proxy(this.itemLeave,this),mousedown:$.proxy(this.itemDown,this),focus:$.proxy(this.itemFocus,this),blur:$.proxy(this.itemBlur,this),click:$.proxy(this.itemClick,this)},i),"a"),i+=this.rootId,this.opts.hideOnClick&&$(document).on(getEventsNS({touchstart:$.proxy(this.docTouchStart,this),touchmove:$.proxy(this.docTouchMove,this),touchend:$.proxy(this.docTouchEnd,this),click:$.proxy(this.docClick,this)},i)),$(window).on(getEventsNS({"resize orientationchange":$.proxy(this.winResize,this)},i)),this.opts.subIndicators&&(this.$subArrow=$("<span/>").addClass("sub-arrow"),this.opts.subIndicatorsText&&this.$subArrow.html(this.opts.subIndicatorsText)),initMouseDetection()}if(this.$firstSub=this.$root.find("ul").each(function(){e.menuInit($(this))}).eq(0),this.$firstLink=this.$root.find("a").eq(0),this.opts.markCurrentItem){var s=/(index|default)\.[^#\?\/]*/i,o=/#.*/,a=window.location.href.replace(s,""),n=a.replace(o,"");this.$root.find("a").each(function(){var t=this.href.replace(s,""),i=$(this);(t==a||t==n)&&(i.addClass("current"),e.opts.markCurrentTree&&i.parentsUntil("[data-smartmenus-id]","ul").each(function(){$(this).dataSM("parent-a").addClass("current")}))})}this.wasCollapsible=this.isCollapsible()},destroy:function(t){if(!t){var e=".smartmenus";this.$root.removeData("smartmenus").removeAttr("data-smartmenus-id").removeDataSM("level").off(e),e+=this.rootId,$(document).off(e),$(window).off(e),this.opts.subIndicators&&(this.$subArrow=null)}this.menuHideAll();var i=this;this.$root.find("ul").each(function(){var t=$(this);t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.dataSM("shown-before")&&((i.opts.subMenusMinWidth||i.opts.subMenusMaxWidth)&&t.css({width:"",minWidth:"",maxWidth:""}).removeClass("sm-nowrap"),t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.css({zIndex:"",top:"",left:"",marginLeft:"",marginTop:"",display:""})),0==(t.attr("id")||"").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeDataSM("in-mega").removeDataSM("shown-before").removeDataSM("scroll-arrows").removeDataSM("parent-a").removeDataSM("level").removeDataSM("beforefirstshowfired").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeAttr("aria-
Line truncated
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
@licstart The following is the entire license notice for the JavaScript code in this file.
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 1997-2020 by Dimitri van Heesch
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@licend The above is the entire license notice for the JavaScript code in this file
|
||||
*/
|
||||
function initMenu(relPath,searchEnabled,serverSide,searchPage,search) {
|
||||
function makeTree(data,relPath) {
|
||||
var result='';
|
||||
if ('children' in data) {
|
||||
result+='<ul>';
|
||||
for (var i in data.children) {
|
||||
var url;
|
||||
var link;
|
||||
link = data.children[i].url;
|
||||
if (link.substring(0,1)=='^') {
|
||||
url = link.substring(1);
|
||||
} else {
|
||||
url = relPath+link;
|
||||
}
|
||||
result+='<li><a href="'+url+'">'+
|
||||
data.children[i].text+'</a>'+
|
||||
makeTree(data.children[i],relPath)+'</li>';
|
||||
}
|
||||
result+='</ul>';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var searchBoxHtml;
|
||||
if (searchEnabled) {
|
||||
if (serverSide) {
|
||||
searchBoxHtml='<div id="MSearchBox" class="MSearchBoxInactive">'+
|
||||
'<div class="left">'+
|
||||
'<form id="FSearchBox" action="'+relPath+searchPage+
|
||||
'" method="get"><span id="MSearchSelectExt"> </span>'+
|
||||
'<input type="text" id="MSearchField" name="query" value="" placeholder="'+search+
|
||||
'" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)"'+
|
||||
' onblur="searchBox.OnSearchFieldFocus(false)"/>'+
|
||||
'</form>'+
|
||||
'</div>'+
|
||||
'<div class="right"></div>'+
|
||||
'</div>';
|
||||
} else {
|
||||
searchBoxHtml='<div id="MSearchBox" class="MSearchBoxInactive">'+
|
||||
'<span class="left">'+
|
||||
'<span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()"'+
|
||||
' onmouseout="return searchBox.OnSearchSelectHide()"> </span>'+
|
||||
'<input type="text" id="MSearchField" value="" placeholder="'+search+
|
||||
'" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" '+
|
||||
'onblur="searchBox.OnSearchFieldFocus(false)" '+
|
||||
'onkeyup="searchBox.OnSearchFieldChange(event)"/>'+
|
||||
'</span>'+
|
||||
'<span class="right"><a id="MSearchClose" '+
|
||||
'href="javascript:searchBox.CloseResultsWindow()">'+
|
||||
'<img id="MSearchCloseImg" border="0" src="'+relPath+
|
||||
'search/close.svg" alt=""/></a>'+
|
||||
'</span>'+
|
||||
'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$('#main-nav').before('<div class="sm sm-dox"><input id="main-menu-state" type="checkbox"/>'+
|
||||
'<label class="main-menu-btn" for="main-menu-state">'+
|
||||
'<span class="main-menu-btn-icon"></span> '+
|
||||
'Toggle main menu visibility</label>'+
|
||||
'<span id="searchBoxPos1" style="position:absolute;right:8px;top:8px;height:36px;"></span>'+
|
||||
'</div>');
|
||||
$('#main-nav').append(makeTree(menudata,relPath));
|
||||
$('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu');
|
||||
if (searchBoxHtml) {
|
||||
$('#main-menu').append('<li id="searchBoxPos2" style="float:right"></li>');
|
||||
}
|
||||
var $mainMenuState = $('#main-menu-state');
|
||||
var prevWidth = 0;
|
||||
if ($mainMenuState.length) {
|
||||
function initResizableIfExists() {
|
||||
if (typeof initResizable==='function') initResizable();
|
||||
}
|
||||
// animate mobile menu
|
||||
$mainMenuState.change(function(e) {
|
||||
var $menu = $('#main-menu');
|
||||
var options = { duration: 250, step: initResizableIfExists };
|
||||
if (this.checked) {
|
||||
options['complete'] = function() { $menu.css('display', 'block') };
|
||||
$menu.hide().slideDown(options);
|
||||
} else {
|
||||
options['complete'] = function() { $menu.css('display', 'none') };
|
||||
$menu.show().slideUp(options);
|
||||
}
|
||||
});
|
||||
// set default menu visibility
|
||||
function resetState() {
|
||||
var $menu = $('#main-menu');
|
||||
var $mainMenuState = $('#main-menu-state');
|
||||
var newWidth = $(window).outerWidth();
|
||||
if (newWidth!=prevWidth) {
|
||||
if ($(window).outerWidth()<768) {
|
||||
$mainMenuState.prop('checked',false); $menu.hide();
|
||||
$('#searchBoxPos1').html(searchBoxHtml);
|
||||
$('#searchBoxPos2').hide();
|
||||
} else {
|
||||
$menu.show();
|
||||
$('#searchBoxPos1').empty();
|
||||
$('#searchBoxPos2').html(searchBoxHtml);
|
||||
$('#searchBoxPos2').show();
|
||||
}
|
||||
if (typeof searchBox!=='undefined') {
|
||||
searchBox.CloseResultsWindow();
|
||||
}
|
||||
prevWidth = newWidth;
|
||||
}
|
||||
}
|
||||
$(window).ready(function() { resetState(); initResizableIfExists(); });
|
||||
$(window).resize(resetState);
|
||||
}
|
||||
$('#main-menu').smartmenus();
|
||||
}
|
||||
/* @license-end */
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
@licstart The following is the entire license notice for the JavaScript code in this file.
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 1997-2020 by Dimitri van Heesch
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@licend The above is the entire license notice for the JavaScript code in this file
|
||||
*/
|
||||
var menudata={children:[
|
||||
{text:"Main Page",url:"index.html"}]}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="12px" height="12px" viewBox="0 0 105.83333 105.83333" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect style="fill:#808080;stroke-width:0" width="105.83333" height="105.83334" x="4.2409692e-08" y="-1.2701158e-06" ry="0" />
|
||||
<rect style="fill:#fcfcfc;stroke-width:0" width="79.375" height="79.375" x="13.229166" y="13.229166" />
|
||||
<rect style="fill:#808080;stroke-width:0" width="52.916668" height="15.874998" x="26.458332" y="44.979168" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 582 B |
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="12px" height="12px" viewBox="0 0 105.83333 105.83333" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect style="fill:#808080;stroke-width:0" width="105.83333" height="105.83334" x="4.2409692e-08" y="-1.2701158e-06" ry="0" />
|
||||
<rect style="fill:#000000;stroke-width:0" width="79.375" height="79.375" x="13.229166" y="13.229166" />
|
||||
<rect style="fill:#808080;stroke-width:0" width="52.916668" height="15.874998" x="26.458332" y="44.979168" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 582 B |
|
After Width: | Height: | Size: 153 B |
|
After Width: | Height: | Size: 169 B |
|
After Width: | Height: | Size: 95 B |
|
After Width: | Height: | Size: 98 B |
|
After Width: | Height: | Size: 114 B |
|
After Width: | Height: | Size: 123 B |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="12px" height="12px" viewBox="0 0 105.83333 105.83333" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect style="fill:#808080;stroke-width:0" width="105.83333" height="105.83334" x="4.2409692e-08" y="-1.2701158e-06" ry="0" />
|
||||
<rect style="fill:#fcfcfc;stroke-width:0" width="79.375" height="79.375" x="13.229166" y="13.229166" />
|
||||
<rect style="fill:#808080;stroke-width:0" width="52.916668" height="15.874998" x="26.458332" y="44.979168" />
|
||||
<rect style="fill:#808080;stroke-width:0" width="15.874998" height="52.916668" x="44.979168" y="26.458332" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 696 B |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="12px" height="12px" viewBox="0 0 105.83333 105.83333" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect style="fill:#808080;stroke-width:0" width="105.83333" height="105.83334" x="4.2409692e-08" y="-1.2701158e-06" ry="0" />
|
||||
<rect style="fill:#000000;stroke-width:0" width="79.375" height="79.375" x="13.229166" y="13.229166" />
|
||||
<rect style="fill:#808080;stroke-width:0" width="52.916668" height="15.874998" x="26.458332" y="44.979168" />
|
||||
<rect style="fill:#808080;stroke-width:0" width="15.874998" height="52.916668" x="44.979168" y="26.458332" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 696 B |
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
viewBox="0 0 11 11"
|
||||
height="11"
|
||||
width="11"
|
||||
id="svg2"
|
||||
version="1.1">
|
||||
<defs
|
||||
id="defs6" />
|
||||
<path
|
||||
id="path12"
|
||||
d="M 5.5 0.5 A 5 5 0 0 0 0.5 5.5 A 5 5 0 0 0 5.5 10.5 A 5 5 0 0 0 10.5 5.5 A 5 5 0 0 0 5.5 0.5 z M 3.5820312 3 A 0.58291923 0.58291923 0 0 1 4 3.1757812 L 5.5 4.6757812 L 7 3.1757812 A 0.58291923 0.58291923 0 0 1 7.4003906 3 A 0.58291923 0.58291923 0 0 1 7.8242188 4 L 6.3242188 5.5 L 7.8242188 7 A 0.58291923 0.58291923 0 1 1 7 7.8242188 L 5.5 6.3242188 L 4 7.8242188 A 0.58291923 0.58291923 0 1 1 3.1757812 7 L 4.6757812 5.5 L 3.1757812 4 A 0.58291923 0.58291923 0 0 1 3.5820312 3 z "
|
||||
style="stroke-width:1.09870648;fill:#bababa;fill-opacity:1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 947 B |
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
viewBox="0 0 20 19"
|
||||
height="19"
|
||||
width="20"
|
||||
id="svg2"
|
||||
version="1.1">
|
||||
<defs
|
||||
id="defs6" />
|
||||
<circle
|
||||
r="3.5"
|
||||
cy="8.5"
|
||||
cx="5.5"
|
||||
id="path4611"
|
||||
style="fill:#000000;fill-opacity:0;stroke:#656565;stroke-width:1.4;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
<path
|
||||
id="path4630"
|
||||
d="m 8.1085854,11.109059 2.7823556,2.782356"
|
||||
style="fill:none;stroke:#656565;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 804 B |