diff options
-rwxr-xr-x | telem.lua | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -101,8 +101,12 @@ function do_board() -- Creates a new (empty) board -- Get details - io.write("New board name? (Max 19 chars) ") -- TODO: Check and enforce 19 chars + io.write("New board name? (Max 18 chars) ") board = string.upper(io.read()) + if string.len(board) > 18 then + print("Board names must be 18 characters or less!") + return + end io.write("Description? ") desc = io.read() -- Create directory @@ -174,6 +178,10 @@ function do_new() -- Get subject for new thread io.write("Subject? ") subject = io.read() + if string.len(subject) > 48 then + print("Thread subjects must be 48 characters or less!") + return + end -- Save body of post to temp file filename = os.tmpname() os.execute("$EDITOR " .. filename) @@ -245,7 +253,11 @@ type_dispatch["d"] = function() return end function do_type() io.write("Display which thread? ") - local thread_id = string.upper(io.read()) + local thread_id = tonumber(io.read()) + if not thread_id or thread_id < 0 or thread_id > #current_thread_index then + print("Invalid thread index!") + return + end thread = current_thread_index[tonumber(thread_id)] current_thread_subject = thread.subject current_thread_posts = get_posts(thread) @@ -288,7 +300,11 @@ function do_reply() return end io.write("Reply to which thread? ") - local thread_id = string.upper(io.read()) + local thread_id = tonumber(io.read()) + if not thread_id or thread_id < 0 or thread_id > #current_thread_index then + print("Invalid thread index!") + return + end thread = current_thread_index[tonumber(thread_id)] current_thread_subject = thread.subject current_thread_posts = get_posts(thread) |