Commit Graph
168 Commits
Author SHA1 Message Date
Brad Arant 14697e2af2 Fix three real bugs found during a full ZString review
operator< computed end2 as valuex.getData() + valuex.getLength() - mixing
an absolute pointer (getData(), the buffer start) with a cursor-relative
length (getLength(), remaining-from-cursor). For any ZString with a
non-zero cursor offset this produces an end pointer short of the true
buffer end by exactly the amount already consumed, truncating the
comparison early. Fixed to use valuex.data + valuex.length (the true
end), matching how end1 was already computed for *this. operator<=,
>=, and > were separately broken (flagged by the codes own TODO
comment) - they compared via strncmp from data (ignoring cursor
entirely), inconsistent with operator< and with each other. Replaced
all three with derivations from the now-correct operator< (a <= b is
!(b < a), etc.) - guarantees trichotomy by construction instead of
three independently-written comparison loops.

substring(start, len): when the requested length overran the buffer,
computed newlen as endChar - end (the overrun amount) instead of
end - startChar (the actual remaining valid length) - backwards, and
stored into a char (max 127), silently wrapping for longer strings.
Fixed the formula and widened to size_t.

trimCRLF(): read *(data + length - 1) unconditionally, including when
length is already 0 - one byte before the buffer on an empty string.
Guarded both checks on length > 0.

Verified: full local compile (identical result to before - 13/20 clean,
same pre-existing StreamReader.h-blocked failures, nothing new broken);
a dedicated runtime test exercising all three fixes plus a trichotomy
check across multiple cursor offsets - all 13 assertions pass. Test
file not included in this commit.
2026-08-22 20:11:13 -07:00
Brad Arant 4082e82466 Fix Exception default file/line always reporting Exception.h itself
__FILE__/__LINE__ are preprocessor macros - as default argument values
in the header they expand once, at the header declaration site, not at
each call site. Every throw relying on the defaults (all but File.cpp,
which passed them explicitly) reported Exception.h itself instead of
the real error location.

Switched the defaults to std::source_location::current(), which the
C++20 standard specifically defines to evaluate at the call site when
used as a default argument - unlike macros. Kept the same 4-parameter
signature so every existing call site, including ones that pass
__FILE__/__LINE__ explicitly, is unaffected.

Verified two ways: full-repo compile pass (identical result to before,
13/20 clean, same pre-existing StreamReader.h-blocked failures, nothing
new broken); a real runtime test - a throw relying on defaults from a
known line correctly reported that exact file/line via the caught
exceptions .file/.line members. Test file not included in this commit.
2026-08-22 19:52:44 -07:00
Brad Arant 29c9a5b855 Fix MString::fromHex() silently swallowing the odd-length-input error
The Exception on the odd-length-input path was constructed but never
thrown (missing throw keyword) - the temporary was destroyed with no
effect, so execution fell through to an out-of-bounds nextChar() read
past the exhausted buffer instead of raising an error. Added the
missing throw.

Verified via full local compile: MString.cpp builds clean standalone;
a full-repo pass shows only the pre-existing, already-known
StreamReader.h-missing failures (7 files, unrelated to this change),
confirmed via each error log individually.
2026-08-22 19:52:35 -07:00
Brad Arant ba85c5f2e5 Still parsing work. 2026-01-05 16:49:41 -08:00
Brad Arant d79697775b Continued work on parsing... 2025-12-31 16:56:00 -08:00
Brad Arant b5652e26cc Still working out parsing buffer stuff. 2025-12-29 16:09:57 -08:00
Brad Arant d415e0abd3 Still working out parsing buffer stuff. 2025-12-18 15:40:37 -08:00
Brad Arant ccfab5aecf Still working out parsing buffer stuff. 2025-12-17 17:07:14 -08:00
Brad Arant 0243468d44 Continued work on Parser. 2025-12-16 16:51:44 -08:00
Brad Arant d54aec1f06 Beginning parser work. 2025-12-15 16:53:49 -08:00
Brad Arant 1542fbe218 Still working out cgi variable stuff. 2025-12-10 16:47:53 -08:00
Brad Arant ab748802ee JFile seems to work well now. 2025-12-09 08:46:33 -08:00
Brad Arant ffa3361fd2 CGIFormData work in progress. 2025-12-08 16:35:15 -08:00
Brad Arant 4988f98223 Started work on JFile. 2025-12-04 17:04:55 -08:00
Brad Arant 829dc1a3c7 Fixed MString and MFile. 2025-12-04 16:40:11 -08:00
Brad Arant 11d6f00bfb Allow - to trigger the number check. 2025-11-25 15:28:31 -08:00
Brad Arant 72c1286053 MFile stuff. 2025-06-20 00:42:24 +00:00
brad Arant a87ce0bab7 JSON file changes 2025-05-17 20:47:09 -07:00
Brad Arant 9cd8381845 significant work on cookies and cgi formdata variables. 2025-03-18 16:46:20 -07:00
Brad Arant bd5223ca36 more cgi processing multiform work. 2025-03-17 16:45:34 -07:00
brad Arant b774e50b59 more session work. 2025-03-17 07:45:02 -07:00
Brad Arant a3d5a4f93f more smartbuffer work. 2025-03-12 09:30:56 -07:00
Brad Arant 2866056072 more IMF work. 2025-03-11 16:59:16 -07:00
brad Arant fd7a9ed860 some smart buffer work. 2025-03-11 07:34:17 -07:00
brad Arant f35fa12902 Merge branch 'develop' of ssh://barant.com/git/CoreUtils into develop 2025-03-07 12:40:56 -08:00
Brad Arant 96f5c02435 Merge branch 'develop' of ssh://barant.com/git/CoreUtils into develop 2025-03-06 14:53:56 -08:00
Brad Arant 25916051e6 added CGIFormattedData object. 2025-03-06 14:47:57 -08:00
brad Arant 11f396a749 worked on IMF smartbuffers. 2025-02-21 13:22:57 -08:00
brad Arant 3f0a541e80 added byte count limiter for read on MString. 2025-02-14 11:56:11 -08:00
Brad Arant 5e6d162a05 added b64 encode/decode to MString. 2025-02-06 14:34:11 -08:00
Brad Arant d1c450fe48 added logic for toupper and tolower on MString. 2025-02-04 15:43:17 -08:00
Brad Arant c40e288a67 added trim operand function. 2025-01-16 13:38:35 -08:00
barant 5fd02a7a44 Fixed data type on comparisons. 2025-01-09 09:04:17 -08:00
barant cfd996fe5a cleanup for valgrind. 2024-12-23 13:00:22 -08:00
barant 0ebe8eaf5b cleanup for valgrind. 2024-12-23 11:15:53 -08:00
barant e5bfd7a840 fixed bug with substring on ZString. 2024-12-23 09:51:10 -08:00
barant 921854e455 fixed bug with asInteger on ZString. 2024-12-23 09:37:14 -08:00
barant f8557aa5f5 migrating conversion modifiers from JetCore::Global to MString. 2024-12-19 10:32:23 -08:00
barant 10df4a6a99 added changed event handler. 2024-12-18 11:26:58 -08:00
barant 7eb2417456 added a pretty output to JString. 2024-12-18 09:49:34 -08:00
barant d74fa9689d added a pretty output to JString. Initial. 2024-12-17 16:56:05 -08:00
barant d1e5e41ab2 JString fix to compress initial assignment JSON. 2024-12-17 09:58:56 -08:00
barant 95254310f0 JString fix to compress initial assignment JSON. 2024-12-17 09:56:55 -08:00
barant 83e9b8ca99 bug fixes on mstring and jstring. 2024-12-12 15:47:09 -08:00
barant 0d60cce8dc more serious work on JString. 2024-12-12 12:22:46 -08:00
barant c6e0486c14 Serious work on JString and some minor MString ajustments. 2024-12-11 16:58:34 -08:00
barant 7531c885a7 JString now streams properly. 2024-12-11 09:55:40 -08:00
barant 0baa44d076 messing around with jstring. 2024-12-10 17:10:49 -08:00
brad Arant c644d8346f fixed asInteger math issue. 2024-11-27 15:26:21 -08:00
brad Arant 6cd2fd6cc1 updated zstring_test to accomodate asInteger. 2024-11-27 15:18:32 -08:00