]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/lily.scm (sanitize-command-option): new function.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 6 Nov 2004 18:09:14 +0000 (18:09 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 6 Nov 2004 18:09:14 +0000 (18:09 +0000)
* scm/framework-tex.scm (header): sanitize TeX paper size.

ChangeLog
scm/framework-tex.scm
scm/lily.scm

index 656afff15406c763d8cac7142c4252fb2862481e..4c10f23372b66532b137e0d7c148b502ac3a2b43 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-11-06  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * scm/lily.scm (sanitize-command-option): new function.
+
+       * scm/framework-tex.scm (header): sanitize TeX paper size. 
+
 2004-11-06  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * scm/lily.scm (postscript->pdf): Remove .pdf file if it
@@ -16,7 +22,7 @@
 
 2004-11-06  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
-       * 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)
index 07bf07b8b26783689eda064532548ad8e2442b8f..0565ed5472ce47ff0e8de29ce1a082829f21f521 100644 (file)
@@ -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))
 
       "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
 ;; 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"))
         (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 "
                                 " ")
index 1031f31bb4a5bb7c821538404748983f0871ada1..ca173e27efead91096fb18b417c1d96545877320 100644 (file)
@@ -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)))