Function: TeX--output-dir-safe-p

TeX--output-dir-safe-p is a byte-compiled function defined in tex.el.

Signature

(TeX--output-dir-safe-p VALUE)

Documentation

Return non-nil if VALUE is safe as a file-local TeX-output-dir.

VALUE is considered safe when it is either nil or a relative path that stays inside the master file's directory, i.e., it must not be absolute and must not contain a .. component.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.2.0/tex.el
(defun TeX--output-dir-safe-p (value)
  "Return non-nil if VALUE is safe as a file-local `TeX-output-dir'.
VALUE is considered safe when it is either nil or a relative path that
stays inside the master file's directory, i.e., it must not be absolute
and must not contain a `..' component."
  (or (null value)
      (and (stringp value)
           ;; We call `make-directory' on `TeX-output-dir' in
           ;; `TeX--master-output-dir' and the value is passed to the
           ;; TeX process as --output-directory; both an absolute path
           ;; and `..' components could escape the document tree, so
           ;; consider them unsafe.
           (not (file-name-absolute-p value))
           ;; TODO: Use `file-name-split' once we bump compatibility to
           ;; emacs >= 29.1.
           (not (member ".." (split-string value "[/\\]" t))))))