From: Han-Wen Nienhuys Date: Sat, 6 Nov 2004 18:09:14 +0000 (+0000) Subject: * scm/lily.scm (sanitize-command-option): new function. X-Git-Tag: release/2.4.2~3^2~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ec36fcfd6b4bd567173e8f85ce59b63d252a4b8c;p=lilypond.git * scm/lily.scm (sanitize-command-option): new function. * scm/framework-tex.scm (header): sanitize TeX paper size. --- diff --git a/ChangeLog b/ChangeLog index 656afff154..4c10f23372 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-11-06 Han-Wen Nienhuys + + * scm/lily.scm (sanitize-command-option): new function. + + * scm/framework-tex.scm (header): sanitize TeX paper size. + 2004-11-06 Jan Nieuwenhuizen * scm/lily.scm (postscript->pdf): Remove .pdf file if it @@ -16,7 +22,7 @@ 2004-11-06 Han-Wen Nienhuys - * scm/lily.scm (ly:system): add > /dev/null 2>&1 + * scm/lily.scm (ly:system): add > /dev/null 2>&1 . (backportme) * lily/recording-group-engraver.cc (derived_mark): mark now_events_. (backportme) diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm index 07bf07b8b2..0565ed5472 100644 --- a/scm/framework-tex.scm +++ b/scm/framework-tex.scm @@ -25,7 +25,7 @@ (if (ly:get-option 'safe) (regexp-substitute/global #f "\\\\" - (regexp-substitute/global #f "([{}])" "bla{}" 'pre "\\" 1 'post ) + (regexp-substitute/global #f "([{}])" s 'pre "\\" 1 'post ) 'pre "$\\backslash$" 'post) s)) @@ -139,7 +139,7 @@ "lilypondpaper" 'linewidth (ly:number->string (* scale (ly:output-def-lookup paper 'linewidth)))) "\\def\\lilyponddocumentclassoptions{" - texpaper + (sanitize-tex-string texpaper) (if landscape? ",landscape" "") "}%\n" (tex-string-def @@ -275,6 +275,8 @@ ;; ugh - double check this. We are leaking ;; untrusted (user-settable) info to a command-line ;; + + (define-public (convert-to-ps book name) (let* ((paper (ly:paper-book-paper book)) (preview? (string-contains name ".preview")) @@ -284,10 +286,10 @@ (cmd (string-append "dvips " (if preview? " -E " - (if (member papersizename - (map car paper-alist)) - (string-append "-t " papersizename) - "")) + (string-append + " -t " + (sanitize-command-option papersizename))) + (if landscape? " -t landscape " " ") diff --git a/scm/lily.scm b/scm/lily.scm index 1031f31bb4..ca173e27ef 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -581,19 +581,25 @@ possibly turned off." (_ "Error invoking `~a'. Return value ~a") silenced status) (newline (current-error-port)))))) -;; -;; ugh - double check this. We are leaking -;; untrusted (user-settable) info to a command-line -;; -;; (regexp-substitute/global #f "[^[:alnum:]]" papersizename 'pre 'post)) +(define-public (sanitize-command-option str) + (string-append + "\"" + (regexp-substitute/global #f "[^-0-9,.a-zA-Z'\"\\]" str 'pre 'post) + "\"")) + (define-public (postscript->pdf papersizename name) - (let* ((set-papersize (if (member papersizename (map car paper-alist)) - (string-append "-sPAPERSIZE=" papersizename " ") - "")) - (cmd (string-append "ps2pdf " set-papersize name)) - (pdf-name (string-append (basename name ".ps") ".pdf"))) + (let* ((cmd (string-append "ps2pdf " + + (string-append + " -sPAPERSIZE=" + (sanitize-command-option papersizename) + " " + name))) + (pdf-name (string-append (basename name ".ps") ".pdf" ))) + (if (access? pdf-name W_OK) (delete-file pdf-name)) + (format (current-error-port) (_ "Converting to `~a'...") pdf-name) (ly:system cmd)))