Validate IMAP UIDs before fetch

ober

80f72626d53d9621ec201660acf625f71708c338

diff --git a/protonmail/imap/client.ss b/protonmail/imap/client.ss
index 1f5f024..185afd3 100644
--- a/protonmail/imap/client.ss
+++ b/protonmail/imap/client.ss
@@ -230,9 +230,21 @@
   (define (take-last n xs)
     (reverse (take n (reverse xs))))
 
+  (define (decimal-uid? uid)
+    (and (string? uid)
+         (> (string-length uid) 0)
+         (let loop ([i 0])
+           (or (= i (string-length uid))
+               (let ([ch (string-ref uid i)])
+                 (and (char>=? ch #\0)
+                      (char<=? ch #\9)
+                      (loop (+ i 1))))))))
+
   (define (fetch-literal-by-uid client uid fetch-item)
+    (unless (decimal-uid? uid)
+      (error 'imap-fetch "invalid decimal UID" uid))
     (let* ([command (string-append
-                      "UID FETCH "
+	                      "UID FETCH "
                       uid
                       " "
                       fetch-item)]