File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
qs-kotlin/src/main/kotlin/io/github/techouse/qskotlin/internal Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -397,6 +397,7 @@ internal object Decoder {
397397 if (parent.isNotEmpty()) segments.add(parent)
398398
399399 var open = first
400+ var unterminated = false
400401 var depth = 0
401402 while (open >= 0 && depth < maxDepth) {
402403 var i2 = open + 1
@@ -420,6 +421,7 @@ internal object Decoder {
420421 }
421422
422423 if (close < 0 ) {
424+ unterminated = true
423425 break // unterminated group; stop collecting
424426 }
425427
@@ -429,13 +431,14 @@ internal object Decoder {
429431 }
430432
431433 if (open >= 0 ) {
432- // When depth > 0, strictDepth can apply to the remainder.
433- if (strictDepth) {
434+ // When depth > 0, strictDepth can apply to a *well-formed* remainder.
435+ // Unterminated remainder is wrapped without throwing.
436+ if (strictDepth && ! unterminated) {
434437 throw IndexOutOfBoundsException (
435438 " Input depth exceeded depth option of $maxDepth and strictDepth is true"
436439 )
437440 }
438- // Stash the remainder as a single segment.
441+ // Stash the remainder—unterminated or overflow— as a single segment.
439442 segments.add(" [" + key.substring(open) + " ]" )
440443 }
441444
You can’t perform that action at this time.
0 commit comments