Commit 36d5a347 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Improve update handle input validation

parent 7c78178c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -66,6 +66,11 @@ func SelfUpdate(logger *zap.Logger, db *sql.DB, updates []*SelfUpdateOp) (Error_
		statements := make([]string, 0)
		params := make([]interface{}, 0)
		if update.Handle != "" {
			if len(update.Handle) > 20 {
				code = BAD_INPUT
				err = errors.New("Handle must be 1-20 characters long")
				return code, err
			}
			statements = append(statements, "handle = $"+strconv.Itoa(index))
			params = append(params, update.Handle)
			index++
+31 −0
Original line number Diff line number Diff line
--[[
 Copyright 2017 The Nakama Authors

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
--]]

local nk = require("nakama")

local client_rpc_test = {}

function client_rpc_test.echo(context, payload)
  return payload
end
nk.register_rpc(client_rpc_test.echo, "client_rpc_test_echo")

function client_rpc_test.fail(context, payload)
  error("fail")
end
nk.register_rpc(client_rpc_test.fail, "client_rpc_test_fail")

return client_rpc_test