diff options
Diffstat (limited to 'support/digestif/digestif/langserver.lua')
-rw-r--r-- | support/digestif/digestif/langserver.lua | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/support/digestif/digestif/langserver.lua b/support/digestif/digestif/langserver.lua index 55bd8c8dd7..bbda819f11 100644 --- a/support/digestif/digestif/langserver.lua +++ b/support/digestif/digestif/langserver.lua @@ -401,15 +401,14 @@ local function write_msg(msg) end local function read_msg() - local headers, msg = {}, nil - for h in io.lines() do - if h == "" or h == "\r" then break end - local k, v = string.match(h, "^([%a%-]+): (.*)") + local headers = {} + for line in io.lines() do + if line == "" or line == "\r" then break end + local k, v = string.match(line, "^([%a%-]+): (.*)") if k then headers[k] = v end end - local len = tonumber(headers["Content-Length"]) - if len then msg = io.read(len) end - return msg, headers + local len = tonumber(headers["Content-Length"]) or 0 + return io.read(len), headers end local function rpc_send(id, result, error_code) @@ -429,6 +428,10 @@ local function rpc_receive() rpc_send(null, request, -32700) os.exit(false) end + if type(request) ~= "table" or type(request.method) ~= "string" then + rpc_send(null, "Invalid request", -32600) + os.exit(false) + end return request.id, request.method, request.params end |