From c90c7353c7f839824302586a785ac6bed4feaf29 Mon Sep 17 00:00:00 2001 From: brad Arant Date: Sun, 24 Nov 2024 11:20:30 -0800 Subject: [PATCH] multipart/formdata now works for cgi variables. Created base for dump tag. --- Global.cpp | 21 +++++-- Global.h | 2 +- JetCore.log | 134 ++++----------------------------------------- JetCore.txt | 10 +++- tests/post.example | 4 +- tests/testpost.jet | 4 +- 6 files changed, 43 insertions(+), 132 deletions(-) diff --git a/Global.cpp b/Global.cpp index c4397dc..d7715e2 100644 --- a/Global.cpp +++ b/Global.cpp @@ -73,7 +73,11 @@ namespace jet { renderVariableName(variable, name, modifier, lvariables); return variables[name]; } if(variable.ifNext(":")) { - // TODO: should only allow CGI variable name. Allow variable substitution. + renderVariableName(variable, name, modifier, lvariables); + if(name.find(":") == -1) { + name << ":0"; + } + return processModifier(cgiVariables[name], modifier); } if(variable.ifNext("@")) { // TODO: should only allow session variables. Allow substitution. } if(variable.ifNext("%")) { @@ -103,8 +107,9 @@ namespace jet { if(variable.ifNext(";")) { renderVariableName(variable, modifier, modifier, lvariables); return; - } - else if(variable.startsWith("$[") || variable.startsWith("#[")) + } else if(variable.ifNext(":")) { + name << ":"; + } else if(variable.startsWith("$[") || variable.startsWith("#[")) name << getVariable(variable, lvariables); else if(variable.ifNext("]")) return; @@ -151,8 +156,14 @@ namespace jet { coreutils::ZString data = formdata.getTokenExclude("-"); // TODO: Fix this parsing. Need a string exclusion method to check for 'boundary'. data.trimCRLF(); formdata.ifNext(boundary); - cgiVariables[name] = data; - std::cout << name << ":[" << data << "]" << std::endl; + int index = 0; + coreutils::MString namex; + do { + namex = ""; + namex << name << ":" << index++; + } while(cgiVariables.count(namex) != 0); + cgiVariables[namex] = data; +// std::cout << namex << ":[" << data << "]" << std::endl; if(formdata.ifNext("--")) break; formdata.goeol(); diff --git a/Global.h b/Global.h index 713c3ff..c56f4a2 100644 --- a/Global.h +++ b/Global.h @@ -27,7 +27,7 @@ namespace jet { void setupFormData(coreutils::ZString &formdata); std::map variables; - std::map cgiVariables; + std::map cgiVariables; std::map sessions; std::map headers; std::map tags; diff --git a/JetCore.log b/JetCore.log index ad0bbb4..b6c35fd 100644 --- a/JetCore.log +++ b/JetCore.log @@ -1,127 +1,17 @@ -This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex 2024.6.24) 1 NOV 2024 14:40 +This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdfetex 2024.11.17) 24 NOV 2024 10:04 entering extended mode restricted \write18 enabled. + file:line:error style messages enabled. %&-line parsing enabled. -**JetCore.txt +**\input ./JetCore.txt (./JetCore.txt -LaTeX2e <2023-11-01> patch level 1 -L3 programming layer <2024-01-22> -(/usr/share/texlive/texmf-dist/tex/latex/base/book.cls -Document Class: book 2023/05/17 v1.4n Standard LaTeX document class -(/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo -File: bk10.clo 2023/05/17 v1.4n Standard LaTeX file (size option) -) -\c@part=\count187 -\c@chapter=\count188 -\c@section=\count189 -\c@subsection=\count190 -\c@subsubsection=\count191 -\c@paragraph=\count192 -\c@subparagraph=\count193 -\c@figure=\count194 -\c@table=\count195 -\abovecaptionskip=\skip48 -\belowcaptionskip=\skip49 -\bibindent=\dimen140 -) -(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def -File: l3backend-pdftex.def 2024-01-04 L3 backend support: PDF output (pdfTeX) -\l__color_backend_stack_int=\count196 -\l__pdf_internal_box=\box51 -) -(./JetCore.aux) -\openout1 = `JetCore.aux'. - -LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 7. -LaTeX Font Info: ... okay on input line 7. -LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 7. -LaTeX Font Info: ... okay on input line 7. -LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 7. -LaTeX Font Info: ... okay on input line 7. -LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 7. -LaTeX Font Info: ... okay on input line 7. -LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 7. -LaTeX Font Info: ... okay on input line 7. -LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 7. -LaTeX Font Info: ... okay on input line 7. -LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 7. -LaTeX Font Info: ... okay on input line 7. -LaTeX Font Info: External font `cmex10' loaded for size -(Font) <12> on input line 9. -LaTeX Font Info: External font `cmex10' loaded for size -(Font) <8> on input line 9. -LaTeX Font Info: External font `cmex10' loaded for size -(Font) <6> on input line 9. - [1 - - -{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2 - -] -(./JetCore.toc -LaTeX Font Info: External font `cmex10' loaded for size -(Font) <7> on input line 4. -LaTeX Font Info: External font `cmex10' loaded for size -(Font) <5> on input line 4. - [3]) -\tf@toc=\write3 -\openout3 = `JetCore.toc'. - - [4] -Chapter 1. -[5 - -] [6 - -] -Chapter 2. -[7] [8 - -] -Chapter 3. -[9{/usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-ts1.enc}] [10 - -] -Chapter 4. - -Overfull \hbox (8.39041pt too wide) in paragraph at lines 100--100 -[]\OT1/cmr/bx/n/12 substring(string, start-position, number-of-characters - [] - -[11] [12 - -] -Chapter 5. -[13] [14 - -] -Chapter 6. -[15] [16] [17] [18] (./JetCore.aux) - *********** -LaTeX2e <2023-11-01> patch level 1 -L3 programming layer <2024-01-22> - *********** - ) -Here is how much of TeX's memory you used: - 508 strings out of 476182 - 9280 string characters out of 5795595 - 1932975 words of memory out of 5000000 - 22573 multiletter control sequences out of 15000+600000 - 564392 words of font info for 57 fonts, out of 8000000 for 9000 - 14 hyphenation exceptions out of 8191 - 35i,6n,50p,185b,189s stack positions out of 10000i,1000n,20000p,200000b,200000s - -Output written on JetCore.pdf (18 pages, 126208 bytes). -PDF statistics: - 103 PDF objects out of 1000 (max. 8388607) - 66 compressed objects within 1 object stream - 0 named destinations out of 1000 (max. 500000) - 1 words of extra memory for PDF output out of 10000 (max. 10000000) +./JetCore.txt:1: Undefined control sequence. +l.1 \documentclass + {book} +? +./JetCore.txt:1: Emergency stop. +l.1 + +End of file on the terminal! +./JetCore.txt:1: ==> Fatal error occurred, no output PDF file produced! diff --git a/JetCore.txt b/JetCore.txt index e38db4e..a63a5f8 100644 --- a/JetCore.txt +++ b/JetCore.txt @@ -1,5 +1,4 @@ \documentclass{book} - \title{JET Extension Tags} \author{Bradford Matthew Arant Sr.} \date{\today} @@ -193,6 +192,15 @@ used for making comments and is ignored by the jet reader. The comments tag has no attributes. +\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{expr} \section{for} diff --git a/tests/post.example b/tests/post.example index 3de5998..28921dd 100644 --- a/tests/post.example +++ b/tests/post.example @@ -19,8 +19,8 @@ Content-Disposition: form-data; name="name" 5 ------WebKitFormBoundaryA1LWIjMAIsdFW9XA -Content-Disposition: form-data; name="name" +Content-Disposition: form-data; name="name2" 6 ------WebKitFormBoundaryA1LWIjMAIsdFW9XA-- - + diff --git a/tests/testpost.jet b/tests/testpost.jet index f1f3c2b..b4d2b3d 100755 --- a/tests/testpost.jet +++ b/tests/testpost.jet @@ -1,4 +1,6 @@ #!../jet-2.0 - +$[:name] +$[:name:3;tohex] +$[:name2;tohex]