all repos — litestore @ 993e0731828efe3a2a4f04d6a2d05641fcad2263

A minimalist nosql document store.

Added validation for JSON files.
h3rald h3rald@h3rald.com
Sun, 25 Feb 2018 15:52:40 +0100
commit

993e0731828efe3a2a4f04d6a2d05641fcad2263

parent

41d0f913c26fe65788a844090d372e07ba514a4e

1 files changed, 12 insertions(+), 0 deletions(-)

jump to
M lib/core.nimlib/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