2 ms·
Is it actually dangerous to use read for user input? (defun read-data () (let ((data (let ((*read-eval* 'nil)) (read)))) (mapcar (la
by sdkmvx 14y ago
Is it actually dangerous to use read for user input?
(defun read-data ()
(let ((data (let ((*read-eval* 'nil)) (read))))
(mapcar
(lambda (x) (format 't "~a: ~a~%" (car x) (cdr x)))
data)))
Then I can
(read-data)
(("a" . 1) ("b" . 2) ("c" . (funcall (lambda () (princ "I ran code!")))))
And the following will print.
a: 1
b: 2
c: (FUNCALL (LAMBDA () (PRINC I ran code!)))
But of course unless I eval the code, arbitrary code will not run (assuming I haven't forgotten some aspect of the reader).