You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe cumulative enforcement, numeric-key overflow, ValueError semantics, and bracketed comma groups across the changelog, public docs, option docstrings, and qs-codec skill.
Copy file name to clipboardExpand all lines: README.rst
+24-7Lines changed: 24 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Highlights
25
25
- Pluggable hooks: custom ``encoder``/``decoder`` callables; options to sort keys, filter output, and control percent-encoding (keys-only, values-only).
26
26
- Nulls & empties: ``strict_null_handling`` and ``skip_nulls``; support for empty lists/arrays when desired.
27
27
- Dates: ``serialize_date`` for ISO 8601 or custom (e.g., UNIX timestamp).
28
-
- Safety limits: configurable decode depth and encode max depth, parameter limit, and list index limit; optional strict-depth errors; duplicate-key strategies (combine/first/last).
28
+
- Safety limits: configurable decode depth and encode max depth, parameter limit, and list element limit; optional strict-depth errors; duplicate-key strategies (combine/first/last).
`decode <https://techouse.github.io/qs_codec/qs_codec.html#module-qs_codec.decode>`__ will also limit specifying indices
501
-
in a ``list`` to a maximum index of ``20``. Any ``list`` members with an
502
-
index of greater than ``20`` will instead be converted to a ``dict`` with
503
-
the index as the key. This is needed to handle cases when someone sent,
504
-
for example, ``a[999999999]`` and it will take significant time to iterate
505
-
over this huge ``list``.
500
+
`decode <https://techouse.github.io/qs_codec/qs_codec.html#module-qs_codec.decode>`__ also limits each ``list`` to a
501
+
maximum element count of ``20``. Index ``19`` is the last index that can create
502
+
a default ``list``; index ``20`` and higher are converted to a ``dict`` with
503
+
the index as the key. This prevents inputs such as ``a[999999999]`` from
504
+
creating massive sparse lists.
506
505
507
506
.. code:: python
508
507
@@ -522,6 +521,24 @@ option:
522
521
qs.DecodeOptions(list_limit=0),
523
522
) == {'a': {'1': 'b'}}
524
523
524
+
The same limit is enforced cumulatively when duplicate keys, mixed list
525
+
notation, or comma-separated values grow a list. A result exactly at the limit
526
+
remains a ``list``. Above the limit, decoding uses a numeric-keyed ``dict`` by
527
+
default, or raises ``ValueError`` when ``raise_on_limit_exceeded=True``.
528
+
529
+
.. code:: python
530
+
531
+
import qs_codec as qs
532
+
533
+
assert qs.decode(
534
+
'a=x&a=y',
535
+
qs.DecodeOptions(list_limit=1),
536
+
) == {'a': {'0': 'x', '1': 'y'}}
537
+
538
+
With ``comma=True``, a flat comma value is subject to the same limit. A value
539
+
assigned through ``[]=`` counts as one outer list element, so its inner
540
+
comma-separated group may contain more values than ``list_limit``.
541
+
525
542
To disable ``list`` parsing entirely, set `parse_lists <https://techouse.github.io/qs_codec/qs_codec.models.html#qs_codec.models.decode_options.DecodeOptions.parse_lists>`__
Copy file name to clipboardExpand all lines: docs/index.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ Highlights
29
29
- Pluggable hooks: custom ``encoder``/``decoder`` callables; options to sort keys, filter output, and control percent-encoding (keys-only, values-only).
30
30
- Nulls & empties: ``strict_null_handling`` and ``skip_nulls``; support for empty lists/arrays when desired.
31
31
- Dates: ``serialize_date`` for ISO 8601 or custom (e.g., UNIX timestamp).
32
-
- Safety limits: configurable decode depth and encode max depth, parameter limit, and list index limit; optional strict-depth errors; duplicate-key strategies (combine/first/last).
32
+
- Safety limits: configurable decode depth and encode max depth, parameter limit, and list element limit; optional strict-depth errors; duplicate-key strategies (combine/first/last).
0 commit comments