C
C#5mo ago
peppy

STJ: Prevent or reverse escaping of base64 string during deserialization

I am using STJ to decode a structure with a string member; the string contains an image in base64 format. Even with Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping set in the JsonSerializerOptions passed to the JsonSerializer.Deserialize call, the input is escaped:
input: (...) DPt+X/ (...)
output: (...) DPtu002BX/ (...)
input: (...) DPt+X/ (...)
output: (...) DPtu002BX/ (...)
Can I obtain the unmodified input in any way? Reading through the docs, I understand that STJ, in the name of safety, has a blacklist of things it will escape regardless of the user's preferences. It seems to me like I can't prevent it from doing it. I tried Regex.Unescape to reverse it, but it does not seem to work, possibly because of the missing backslash in front of u002B. How can I obtain the input exactly as given?
0 Replies
No replies yetBe the first to reply to this messageJoin