Description
I have an excel client using vba-web which interacts with a server, passing data back and forth in json. The excel client passes up certain values in json which contain newlines (/n, chr(10), LF), which come from excel multivalue(multiline) cells. The server stores them ok, and passes them back later when requested.
However, when decoding the received json using the webhelpers module from VBA-WEB (and I realize this is also applicable to VBA-JSON), a "/r" is appended to all "/n" due to the case statement decoding. This breaks things since the client (and excel ) will misintepret the result, because the /n is used in excel for multi-value cells.
The offending line in json_ParseString is here:
Case "n" json_BufferAppend json_buffer, vbCrLf, json_BufferPosition, json_BufferLength json_Index = json_Index + 1
Here the \n case is translated to vbCrLf, instead of just vbLF.
This is different than the /r case, which only translates to vbCr
Case "r" json_BufferAppend json_buffer, vbCr, json_BufferPosition, json_BufferLength json_Index = json_Index + 1
For a simple patch workaround, I changed the case n to:
Case "n" json_BufferAppend json_buffer, vbLf, json_BufferPosition, json_BufferLength json_Index = json_Index + 1
I realize that line terminator issues between windows/linux can be complex, this change still seems correct. If there were actually a /r/n sequence in the decode, the case statement would find each and individually replace them. But I suppose there are lazy instances where this is not noticed/critical, or perhaps an expected assumption at the windows termination side.