diff options
author | Tim <t4im@users.noreply.github.com> | 2015-02-02 19:33:41 +0100 |
---|---|---|
committer | Tim <t4im@users.noreply.github.com> | 2015-02-03 00:22:59 +0100 |
commit | dc58fe8467f7be6ca0a5fe7822f1ed80450cff98 (patch) | |
tree | c6a170d9bcf84c4a3f47843351ba3d69484a36d1 | |
parent | 95a6ec93e7499da8e6835794d0cf73a6f3bd7bed (diff) | |
download | pipeworks-dc58fe8467f7be6ca0a5fe7822f1ed80450cff98.tar pipeworks-dc58fe8467f7be6ca0a5fe7822f1ed80450cff98.tar.gz pipeworks-dc58fe8467f7be6ca0a5fe7822f1ed80450cff98.tar.bz2 pipeworks-dc58fe8467f7be6ca0a5fe7822f1ed80450cff98.tar.xz pipeworks-dc58fe8467f7be6ca0a5fe7822f1ed80450cff98.zip |
trim teleport_tube string input
-rw-r--r-- | teleport_tube.lua | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/teleport_tube.lua b/teleport_tube.lua index c00bc0a..8647e8d 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -154,27 +154,29 @@ pipeworks.register_tube("pipeworks:teleport_tube", { meta:set_string("infotext", "unconfigured Teleportation Tube") end, on_receive_fields = function(pos,formname,fields,sender) - if not fields.channel then + local new_channel = tostring(fields.channel) + if not new_channel then return -- ignore escaping or clientside manipulation of the form end + new_channel = new_channel:trim() local meta = minetest.get_meta(pos) local can_receive = meta:get_int("can_receive") -- check for private channels each time before actually changing anything -- to not even allow switching between can_receive states of private channels - if fields.channel ~= "" then + if new_channel ~= "" then local sender_name = sender:get_player_name() - local name, mode = fields.channel:match("^([^:;]+)([:;])") + local name, mode = new_channel:match("^([^:;]+)([:;])") if name and mode and name ~= sender_name then --channels starting with '[name]:' can only be used by the named player if mode == ":" then - minetest.chat_send_player(sender_name, "Sorry, channel '"..fields.channel.."' is reserved for exclusive use by "..name) + minetest.chat_send_player(sender_name, "Sorry, channel '"..new_channel.."' is reserved for exclusive use by "..name) return --channels starting with '[name];' can be used by other players, but cannot be received from elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then - minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..fields.channel.."' is reserved for "..name) + minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..new_channel.."' is reserved for "..name) return end end @@ -184,8 +186,8 @@ pipeworks.register_tube("pipeworks:teleport_tube", { -- was the channel changed? local channel = meta:get_string("channel") - if fields.channel ~= channel then - channel = fields.channel + if new_channel ~= channel then + channel = new_channel meta:set_string("channel", channel) dirty = true end |