Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape single quotes in json #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/WebHelpers.bas
Original file line number Diff line number Diff line change
Expand Up @@ -2539,11 +2539,15 @@ Private Function json_Encode(ByVal json_Text As Variant) As String
End If

' From spec, ", \, and control characters must be escaped (solidus is optional)

' To avoid problems with quoting the payload on the command line in single quotes, need to escape ' also

Select Case json_AscCode
Case 34
' " -> 34 -> \"
json_Char = "\"""
Case 39
' ' -> 39 -> \u0027 (decimal 39 is 27 in hex)
json_Char = "\u0027"
Case 92
' \ -> 92 -> \\
json_Char = "\\"
Expand Down