Check input of NTP conversion function

master
Daniel Borchmann 3 years ago
parent 57107c0c75
commit df2464ce5b
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
  1. 10
      site-lisp/db-utils.el

@ -206,10 +206,12 @@ might depend on the coding system of the current buffer."
HIGH and LOW must both be 8 digit hex strings. If not given,
FORMAT-STRING defaults to some ISO 8601-like format."
(interactive (cl-flet ((read-hex (prompt)
(string-to-number (->> prompt
(read-string)
(replace-regexp-in-string "[\n\t ]" ""))
16)))
(let ((input-proper (->> prompt
(read-string)
(replace-regexp-in-string "[\n\t ]" ""))))
(if (not (string-match-p "[0-9a-fA-F]\\{8\\}" input-proper))
(user-error "Input invalid, must be an 8 digit hex string.")
(string-to-number input-proper 16)))))
(list (read-hex "High (hex): ")
(read-hex "Low (hex): "))))
(let* ((high-seconds (- high 2208988800)) ; subtract seconds between 1900-01-01 and the epoch

Loading…
Cancel
Save