Commit Graph
38 Commits
Author SHA1 Message Date
Brad ArantandClaude Sonnet 5 fc849c44a4 Back $[@name] session variables with a JSON file via JFile, reusing the @ sigil
The @ sigil previously read through global.getSession(global.sessionId),
a MySQL-session binding that was already confirmed dead this session -
Global::sessionId is never assigned anywhere in the codebase, so any
$[@name] read would always throw. The design goal: persist session state
as a JSON file at sessiondir/<sessionId>.json, using CoreUtils's existing
JFile (an MFile+JString combination with load-on-construct/save-on-
destruct RAII semantics), reusing @ rather than introducing a new sigil
since the old @ usage was unreachable in practice anyway.

Global.h/.cpp: added Global::sessionFile (a JFile*, NULL unless a request
is in cgi mode with sessiondir set). Its destructor now explicitly
deletes sessionFile - JFile's actual disk write happens in MFile's
destructor via update(), so this has to run for persistence to happen at
all (a raw `new`'d pointer that's never deleted, as cgiData still is,
would never save anything back to disk).

__jet.cpp: the sessiondir block now builds the session file path from the
sessiondir keyword and the active session id (existing cookie or newly
issued) and constructs global.sessionFile there, for both branches. The
"pull sessionfile from sessiondir" comment is now implemented - JFile's
own constructor already handles "file doesn't exist yet" by loading as
empty, so one construction point serves both a resumed and a brand-new
session.

Tag.cpp: getVariable's "@" branch now reads via (*global.sessionFile)[name]
with a clear error if no session is active, instead of the dead MySQL
lookup. Added Tag::assignVariable (declared in Tag.h), a single write
path both storeVariable overloads now funnel through, so a "@name"-
prefixed target (e.g. <set name="@x" value="y"/>) is routed to the
session file instead of the normal global/local/parent variables maps -
without this, the read side would have been read-only, which isn't a
very useful session mechanism.

This surfaced two real, pre-existing CoreUtils bugs, both fixed
separately (see CoreUtils commit 3e6e410): JFile's virtual-base diamond
skipping JString's own empty-object seed, and MString's ZString-source
copy paths pairing an absolute data pointer with a cursor-relative
length - both were silently corrupting any cursor-advanced ZString
(exactly what assignVariable produces when it strips the "@" prefix via
ifNext() before storing).

Verified live: two genuinely separate jet-2.0 process invocations
sharing one session cookie, where the first writes two session
variables and the second - a fresh process with no shared memory - reads
both back correctly from the JSON file on disk. Also re-ran
tests/posttest.sh (unchanged output, no regression) and the full
CoreUtils test suite (no regressions).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 18:45:21 -07:00
Brad ArantandClaude Sonnet 5 2d9505cd33 Fix jet cgi=yes CGI variable loading and related bugs
- __jet.cpp: the cgi keyword check compared against "true" but the
  documented/intended value is "yes", so <jet cgi="yes" ...> never
  actually turned CGI mode on; fixed. Also replaced the hardcoded
  fake multipart boundary ("xxxx") with real extraction from the
  Content-Type header's boundary= parameter.
- Global.h: default-initialize cgiData to NULL (a GET request with
  cgi="yes" never allocates it, so it was previously left
  dangling); Global.cpp now sets the cookie jar's delimiter to ";"
  to match RFC 6265, since it defaulted to CGIFormattedData's
  &-based form-data delimiter.
- Global.cpp: fix addSession()'s missing throw that let it silently
  continue past a duplicate session id.
- Tag.cpp: fix the CGI-variable lookup branch, which failed to
  compile (cgiData is a pointer; needed to dereference it before
  indexing) and added a null check so a CGI request that never
  populated cgiData (bad Content-Type, or the null-safety gap
  above) throws a clear error instead of crashing; implemented the
  previously-empty session-variable lookup branch; left the
  unreachable duplicate environment-variable branch as-is with a
  comment, since fixing its sigil is a user-facing template-syntax
  decision, not a bug fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-22 21:37:51 -07:00
Brad Arant 3bd9ea124f Continued work on cgi interfaces. 2025-12-09 12:29:39 -08:00
barant 5c27df59da work towards a clean compile on migrating set and get variables from Tag. 2025-01-08 10:27:30 -08:00
barant 2549220914 migrating getvariable and setvarable to Tag. Needs alot of work. 2025-01-06 14:57:48 -08:00
brad Arant f6dda8496c Made $[%name] to retrieve keyword values in a tag. Has bugs. 2025-01-03 10:50:31 -08:00
brad Arant 907f449ecc Started the cookie tag. Still needs work. 2025-01-02 09:48:31 -08:00
brad Arant af7080e011 fixed local scoping on call tag. 2024-12-21 21:03:17 -08:00
brad Arant 9a9abab92d fixed scoping for local on for tag. 2024-12-21 20:26:46 -08:00
barant f3b66d9770 make uninitialized global and local variables cause exception. 2024-12-09 16:24:19 -08:00
brad Arant ae57e06778 fixed mysql tag to give values for ?# # and field name using #n. 2024-11-27 15:37:58 -08:00
Brad Arant ca7aabd73f more sever scoping work. 2024-11-26 16:57:03 -08:00
Brad Arant e3d788bc92 error reporting now reports accurately to the line. 2024-11-26 11:17:22 -08:00
brad Arant a9ce087939 urlencoded forms data is now workng as well. 2024-11-24 13:21:44 -08:00
brad Arant c90c7353c7 multipart/formdata now works for cgi variables. Created base for dump tag. 2024-11-24 11:20:30 -08:00
brad Arant c21dea1411 some cgi variable work. 2024-11-23 19:25:14 -08:00
Brad Arant b0453fe0cb worked on error output just a little. 2024-11-18 16:59:32 -08:00
Brad Arant 5a7f7f2d18 fixed up call tag. Should be complete. 2024-11-18 12:44:41 -08:00
Brad Arant 7fbbac4a65 Laid foundation for modifiers and built a couple. 2024-11-13 14:51:34 -08:00
Brad Arant 31e309934c Setup base for conversion modifiers to be written. 2024-11-07 16:47:11 -08:00
Brad Arant 527e8bf778 Fixed read tag to throw exception on file error unstead of looping forever. 2024-10-31 16:05:46 -07:00
Brad Arant f0b3c0e0f6 Functional variable retrieval including #[local]. 2024-10-17 15:57:35 -07:00
Brad Arant 062a023683 Broken everything trying to get variable stuff situated. 2024-10-17 14:02:02 -07:00
Brad Arant 4972799e7a Fucked up variable handling trying to improve things with a modifier. 2024-10-16 16:58:33 -07:00
Brad Arant 7d6bb8355f Created $[$name] retrieve for environment variables. 2024-10-07 13:33:17 -07:00
brad Arant cc904693ab More work on output and some cleanup of temporary cout messages. 2024-09-26 21:21:21 -07:00
brad Arant c6c0be016e Fixed whilerow. 2024-09-26 21:11:52 -07:00
Brad Arant 5a97da3d1c Fixed some Expression and Operand memory issues. 2024-09-26 16:58:55 -07:00
Brad Arant 3db9227adc Finished up whilerow. Added hearder tag. 2024-09-26 10:29:33 -07:00
brad Arant 9977ca188c sql variables work now. 2024-09-25 19:57:51 -07:00
brad Arant 387203f4b3 Work on mysql and sql. 2024-09-24 20:20:29 -07:00
Brad Arant 2e715a4d08 Worked on the mysql variable retrieval foundation. 2024-09-24 16:27:38 -07:00
Brad Arant 933c400922 Variables work. Added trimline support. 2024-09-24 12:13:06 -07:00
Brad Arant 3679644f64 More work on Global getVariabke. 2024-09-23 17:07:32 -07:00
Brad Arant 0379974d5e more work on variables. 2024-09-19 14:40:07 -07:00
Brad Arant 7453db9bd9 mysql efforts... 2024-09-18 16:52:08 -07:00
Brad Arant 3d98448ec4 continued development 2024-02-16 20:16:14 -08:00
Brad Arant bb7be37fd6 Making it work but it doesnt 2024-02-16 11:13:10 -08:00