VBA-tools / VBA-JSON

JSON conversion and parsing for VBA
MIT License
1.74k stars 565 forks source link

Resolve infinity loop problem with invalid arrays #256

Open tehniss-nenad opened 11 months ago

tehniss-nenad commented 11 months ago

Before this patch, the application hangs if you do not close the array or string in array. For example "['val1','val2','val3]" or "['val1','val2','val3'"

Nick-vanGemeren commented 11 months ago

Fine as far as it goes, although I would have rewritten the wholeIfas aSelect Case.

ButParseObjecthas the same issue. Both issues (and maybe others) can be solved by testing injson_SkipSpaces:

Private Sub json_SkipSpaces(json_String As String, ByRef json_Index As Long)
    ' Increment index to skip over spaces
    Do While VBA.Mid$(json_String, json_Index, 1) = " "
        json_Index = json_Index + 1
    Loop
    If json_Index > VBA.Len(json_String) Then
        Err.Raise 10001, "JSONConverter", json_ParseErrorMessage(json_String, _
             json_Index, "Unexpected end of input string - missing terminator?")
    End If
End Sub
tehniss-nenad commented 11 months ago

I agree, json_SkipSpaces is better place.