From 0e9420bc8ff2a9ff9dc7b3c032f8db1c7cc01b41 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 1 Mar 2022 15:24:08 +0100 Subject: [PATCH] Reject invalid time-string in appt-add immediately * lisp/calendar/appt.el (appt-add): Check the provided time-string for validity immediately after reading it rather than after reading all the parameters. (Bug#54210) --- lisp/calendar/appt.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el index ebdafb438e3..a7d13cff9a1 100644 --- a/lisp/calendar/appt.el +++ b/lisp/calendar/appt.el @@ -510,9 +510,13 @@ The time should be in either 24 hour format or am/pm format. Optional argument WARNTIME is an integer (or string) giving the number of minutes before the appointment at which to start warning. The default is `appt-message-warning-time'." - (interactive "sTime (hh:mm[am/pm]): \nsMessage: \n\ -sMinutes before the appointment to start warning: ") - (unless (string-match appt-time-regexp time) + (interactive (list (let ((time (read-string "Time (hh:mm[am/pm]): "))) + (unless (string-match-p appt-time-regexp time) + (user-error "Unacceptable time-string")) + time) + (read-string "Message: ") + (read-string "Minutes before the appointment to start warning: "))) + (unless (string-match-p appt-time-regexp time) (user-error "Unacceptable time-string")) (and (stringp warntime) (setq warntime (unless (string-equal warntime "")