Added validation for JSON files.
h3rald h3rald@h3rald.com
Sun, 25 Feb 2018 15:52:40 +0100
1 files changed,
12 insertions(+),
0 deletions(-)
jump to
M
lib/core.nim
→
lib/core.nim
@@ -174,6 +174,12 @@ var searchable = searchable
if binary == 1: searchable = 0 var data = rawdata + if contenttype == "application/json": + # Validate JSON data + try: + discard data.parseJson + except: + raise newException(JsonParsingError, "Invalid JSON content - " & getCurrentExceptionMsg()) if id == "": id = $genOid() elif id.isFolder:@@ -211,6 +217,12 @@ let singleOp = not LS_TRANSACTION
var contenttype = contenttype.replace(peg"""\;(.+)$""", "") # Strip charset for now var binary = checkIfBinary(binary, contenttype) var data = rawdata + if contenttype == "application/json": + # Validate JSON data + try: + discard data.parseJson + except: + raise newException(JsonParsingError, "Invalid JSON content - " & getCurrentExceptionMsg()) var searchable = searchable if binary == 1: searchable = 0