Commit Graph
1496 Commits
Author SHA1 Message Date
Sean Leary 34efda6423 pre-release-20260814 initial commit 2026-08-14 10:54:22 -05:00
Sean Leary 22ab2fb724 Update jar file link in README 2026-07-31 15:28:31 -05:00
Sean Leary 392a352901 Fix formatting of the latest release jar file link 2026-07-31 15:26:28 -05:00
Sean Leary b594a3229c Merge pull request #1070 from dong0713/fix/xml-unescape-whitespace-control-chars
Fix XML.unescape rejecting valid whitespace numeric character references
2026-07-29 07:50:07 -05:00
dong0713 94854a1dfa Fix XML.unescape rejecting valid whitespace numeric character references
XML.mustEscape() is shared by both XML.escape() (serialization) and
XMLTokener.unescapeEntity() (deserialization). While the method's Javadoc
and comment quote the W3C XML 1.0 valid-character range
(#x9 | #xA | #xD | [#x20-#xD7FF] | ...), the implementation only checked
[#x20-#xD7FF] in its range clause, omitting #x9/#xA/#xD.

Although the ISO-control clause excluded those three codepoints, the
negated range clause still marked them as 'must escape', so unescapeEntity()
threw JSONException for the XML-allowed control characters TAB, LF and CR.

This broke XML.unescape("&#10;") and XML.toJSONObject("<a>&#10;</a>"),
both of which worked in v20251224 and regressed after #1045 (v20260522).

Align the range clause with the W3C spec by explicitly allowing #x9, #xA
and #xD, matching the comment that was already documented.

Fixes #1059
2026-07-20 17:42:02 +08:00
Sean Leary 1795e8cf26 Merge pull request #1069 from stleary/pre-release-20260719
20260719 prep for next release
20260719
2026-07-19 14:04:18 -05:00
Sean Leary da757c6656 pre-release-20260719 oops forgot to update new unit tests for strict mode 2026-07-19 13:48:18 -05:00
Sean Leary d24bc9e5d6 pre-release-20260719 initial commit 2026-07-19 12:51:08 -05:00
Sean Leary 80efb529d7 Merge pull request #1068 from stleary/max-number-length-config
Max number length config for BigInteger and BigDecimal
2026-07-19 12:43:09 -05:00
Sean Leary 9953b76050 max-number-length-config sonarqube fixes 2026-07-16 13:23:39 -05:00
Sean Leary a28328c706 Merge pull request #1067 from mechko/1063-biginteger-exponent-dos
#1063: bound BigDecimal→BigInteger expansion in objectToBigInteger (completes CVE-2026-59171 fix)
2026-07-16 12:31:17 -05:00
Mirko SwillusandClaude 703ac34a55 #1063: add JSONParserConfiguration overloads for getBigInteger/optBigInteger
Per review on #1067:
- objectToBigInteger(val, dflt, JSONParserConfiguration) uses
  cfg.getMaxNumberLength() for the digit-count guard; -1 disables it.
  Existing 2-arg form delegates with a default config.
- New public overloads on JSONObject and JSONArray:
  getBigInteger(key, cfg) / optBigInteger(key, dflt, cfg).
  Existing methods delegate with a default config.
- objectToBigDecimal left unchanged (no expansion path; agreed on PR).
- Tests cover default (1000), raised (2000), lowered (5), disabled (-1),
  null config, and JSONArray overloads.

Co-Authored-By: Claude <[email protected]>
2026-07-16 11:42:40 +02:00
Mirko SwillusandClaude e40d933d50 #1063: add comment to expected-exception catch block (SonarCloud java:S108)
Co-Authored-By: Claude <[email protected]>
2026-07-14 13:36:46 +02:00
Mirko SwillusandClaude fce83c91bb #1063: bound BigDecimal->BigInteger expansion in objectToBigInteger
Completes the CVE-2026-59171 fix started in ab92bb9 / #1065. The
1000-char length guard in stringToValue admits short exponent-notation
literals (e.g. 1e100000000, 11 chars) which are stored compactly as
BigDecimal and only expand when getBigInteger/optBigInteger calls
BigDecimal.toBigInteger(), materialising ~10^8 digits and stalling the
thread or throwing OOM.

Guard both toBigInteger() sites in objectToBigInteger by rejecting any
BigDecimal whose integer part would exceed
ParserConfiguration.DEFAULT_MAX_NUMBER_LENGTH decimal digits
(precision() - scale(), both O(1) reads). Returns defaultValue on
overflow, matching the method's existing behaviour for non-finite and
unparseable values.

Covers JSONObject.getBigInteger/optBigInteger and
JSONArray.getBigInteger/optBigInteger (all delegate to this helper).

Adds JSONObjectTest.getBigIntegerHugeExponentReturnsDefault with a 5s
timeout so a regression fails fast rather than hanging CI.

Co-Authored-By: Claude <[email protected]>
2026-07-14 11:59:27 +02:00
Sean Leary 90563eb877 1063-option-3 parserConfig set max len 2026-07-13 15:33:12 -05:00
Sean Leary 1efb5f6c43 Merge pull request #1065 from Damien-Warren-206/master
Fixes CVE-2026-59171
2026-07-06 12:23:25 -05:00
Damien Warren ab92bb9088 Fixes CVE-2026-59171 2026-07-03 09:21:58 -07:00
Sean Leary c91d821dbe Merge pull request #1062 from Fahmida-Hossain-Charu/pr/refactor-cdl-row-serialization
Refactor CDL row serialization for readability
2026-06-21 07:09:27 -05:00
Sean Leary 4a23fd8d9b Merge pull request #1061 from stleary/restore-lenient-jsonarray
restore-lenient-jsonarray allow consecutive commas and insert null
2026-06-18 11:02:35 -05:00
Fahmida-Hossain-Charu 8353b59fa0 Address CDL row serialization review comments 2026-06-17 17:59:07 +06:00
Fahmida-Hossain-Charu 26ee6eb25a Refactor CDL row serialization 2026-06-17 04:17:48 +06:00
Sean Leary ad26e94274 restore-lenient-jsonarray fix some sonarcube issues 2026-06-15 20:56:17 -05:00
Sean Leary c073157a61 restore-lenient-jsonarray initial commit 2026-06-15 16:43:46 -05:00
Sean Leary 33a4698428 Merge pull request #1058 from stleary/docs-and-warnings-cleanup
docs-and-warnings-cleanup
2026-06-01 09:34:43 -05:00
Sean Leary d84fa1af88 docs-and-warnings-cleanup cleanup some doc files, update pom for deployment, fix some JSONObject warnings 2026-05-29 10:38:42 -05:00
Sean Leary 968a592260 Merge pull request #1054 from stleary/pre-release-20260522
pre-release-20260522 prep for next release
20260522
2026-05-22 12:57:40 -05:00
Sean Leary 3665aad82b pre-release-20260522 doc and build updates for release 2026-05-22 12:54:09 -05:00
Sean Leary d749ee16ab Merge pull request #1053 from stleary/update-security-md-with-key
update security.md with key data
2026-05-15 21:35:37 -05:00
Sean Leary 649598338f update-security-md-with-key new security.md file, also fixed 1000 level jsonarray test that fails on my laptop 2026-05-11 11:54:52 -05:00
Sean Leary 896ce0fb74 Merge pull request #1046 from yuki-matsuhashi/master
Validate XML numeric character references before string construction
2026-03-26 11:52:49 -05:00
Yuki Matsuhashi 1877069780 Validate XML numeric character references before string construction 2026-03-24 04:22:50 +09:00
Sean Leary b959027aa2 Merge pull request #1044 from yuki-matsuhashi/1043-ignore-static
Ignore static fields in JSONObject.fromJson()
2026-03-16 09:24:24 -05:00
Yuki Matsuhashi 039f331d7d Add comment for empty test constructor 2026-03-13 01:54:58 +09:00
Yuki Matsuhashi 94e340002b Ignore static fields in JSONObject.fromJson() 2026-03-13 01:23:59 +09:00
Sean Leary 6230128f59 Merge pull request #1041 from stleary/license-clarification
Enhance README with license clarification
2026-02-22 15:14:00 -06:00
Sean Leary ff264ef647 Enhance README with license clarification
Added license clarification
2026-02-18 14:50:17 -06:00
Sean Leary a37aa69480 Merge pull request #1039 from pratiktiwari13/bugfix/empty-force-list
Fixes the issue of losing the array if an empty forceList element or a tag is in the middle or the end
2026-02-03 11:15:58 -06:00
Pratik Tiwari 510a03ac36 Fixes #1040, Aligns non-forceList behaviour with forceList 2026-01-31 10:34:24 +05:30
Sean Leary 538afc3d78 Merge pull request #1038 from OwenSanzas/fix-xmltokener-unescapeentity
Fix input validation in XMLTokener.unescapeEntity()
2026-01-30 08:13:34 -06:00
Sean Leary d092d0903c Merge pull request #1037 from OwenSanzas/fix-jsonml-classcast
Fix ClassCastException in JSONML.toJSONArray and toJSONObject
2026-01-30 08:12:16 -06:00
Pratik Tiwari 7a8da886e7 Remove unnecessary conditions 2026-01-30 19:29:46 +05:30
OwenSanzas 0737e04f8a Add unit tests for JSONML ClassCastException fix
Added comprehensive test coverage for safe type casting:

Exception cases (should throw JSONException, not ClassCastException):
- Malformed XML causing type mismatch in toJSONArray()
- Type mismatch in toJSONObject()

Valid cases (should continue to work):
- Valid XML to JSONArray conversion
- Valid XML to JSONObject conversion

These tests verify the fix for issue #1034 where ClassCastException
was thrown when parse() returned unexpected types.
2026-01-28 10:07:34 +00:00
OwenSanzas 592e7828d9 Add unit tests for XMLTokener.unescapeEntity() input validation
Added comprehensive test coverage for numeric character reference parsing:

Exception cases (should throw JSONException):
- Empty numeric entity: &#;
- Invalid decimal entity: &#txx;
- Empty hex entity: &#x;
- Invalid hex characters: &#xGGG;

Valid cases (should parse correctly):
- Decimal entity: &#65; -> 'A'
- Lowercase hex entity: &#x41; -> 'A'
- Uppercase hex entity: &#X41; -> 'A'

These tests verify the fixes for issues #1035 and #1036.
2026-01-28 09:58:35 +00:00
OwenSanzas 6c1bfbc7a5 Refactor XMLTokener.unescapeEntity() to reduce complexity
Extracted hex and decimal parsing logic into separate methods to
address SonarQube complexity warning:
- parseHexEntity(): handles &#xABC; format
- parseDecimalEntity(): handles &#123; format

This reduces cyclomatic complexity while maintaining identical
functionality and all validation checks.
2026-01-28 09:52:25 +00:00
OwenSanzas 534ce3c4d1 Fix input validation in XMLTokener.unescapeEntity()
Fix StringIndexOutOfBoundsException and NumberFormatException in
XMLTokener.unescapeEntity() when parsing malformed XML numeric
character references.

Issues:
- &#; (empty numeric reference) caused StringIndexOutOfBoundsException
- &#txx; (invalid decimal) caused NumberFormatException
- &#xGGG; (invalid hex) caused NumberFormatException

Changes:
- Add length validation before accessing character positions
- Add isValidHex() and isValidDecimal() helper methods
- Throw proper JSONException with descriptive messages

Fixes #1035, Fixes #1036
2026-01-27 11:40:18 +00:00
OwenSanzas 9d14246bee Fix ClassCastException in JSONML.toJSONArray and toJSONObject
Add type checking before casting parse() results to JSONArray/JSONObject.
When parse() returns an unexpected type (e.g., String for malformed input),
the code now throws a descriptive JSONException instead of ClassCastException.

This prevents unchecked exceptions from propagating to callers who only
expect JSONException from these methods.

Fixes #1034
2026-01-27 11:36:46 +00:00
Pratik Tiwari 995fb840f7 Fixes the issue of losing the array if an empty forceList element or a tag is in the middle or the end 2026-01-02 21:20:53 +05:30
Sean Leary e635f40238 Merge pull request #1027 from Simulant87/1023-set-default-locale
Save/restore default locale in test
2025-12-29 19:42:57 -06:00
Sean Leary d5e744ca90 Merge pull request #1028 from Simulant87/fix-sonarqube-reliability-issues
Refactoring: Fix sonarqube reliability issues
2025-12-29 19:42:02 -06:00
Sean Leary e0c4086168 Merge pull request #1029 from Simulant87/external-javadoc-badge
add badge to external hosted javadoc
2025-12-29 19:41:31 -06:00