diff --git a/cpdf.ml b/cpdf.ml index e8c5d36..68f3ec8 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -70,7 +70,7 @@ let find_cpdflin provided = of the cpdflin binary. Returns the exit code. *) let call_cpdflin cpdflin temp output best_password = let command = - cpdflin ^ " --linearize " ^ " --password=" ^ best_password ^ " " ^ + Filename.quote cpdflin ^ " --linearize " ^ " --password=" ^ best_password ^ " " ^ Filename.quote temp ^ " " ^ Filename.quote output in match Sys.os_type with @@ -87,8 +87,8 @@ let call_cpdflin cpdflin temp output best_password = Sys.command command | _ -> let command = - "DYLD_FALLBACK_LIBRARY_PATH=" ^ Filename.dirname cpdflin ^ " " ^ - "LD_LIBRARY_PATH=" ^ Filename.dirname cpdflin ^ " " ^ + "DYLD_FALLBACK_LIBRARY_PATH=" ^ Filename.quote (Filename.dirname cpdflin) ^ " " ^ + "LD_LIBRARY_PATH=" ^ Filename.quote (Filename.dirname cpdflin) ^ " " ^ command in if !debug then prerr_endline command; diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 3af6bef..f536c06 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -2346,9 +2346,9 @@ let embed_missing_fonts fi fo = exit 2 end; let gscall = - args.path_to_ghostscript ^ - " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ fo ^ - " -dBATCH " ^ fi + Filename.quote args.path_to_ghostscript ^ + " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ Filename.quote fo ^ + " -dBATCH " ^ Filename.quote fi in match Sys.command gscall with | 0 -> exit 0 @@ -2365,9 +2365,9 @@ let mend_pdf_file_with_ghostscript filename = let tmpout = Filename.temp_file "cpdf" ".pdf" in tempfiles := tmpout::!tempfiles; let gscall = - args.path_to_ghostscript ^ - " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ tmpout ^ - " -dBATCH " ^ filename + Filename.quote args.path_to_ghostscript ^ + " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ Filename.quote tmpout ^ + " -dBATCH " ^ Filename.quote filename in match Sys.command gscall with | 0 -> Printf.eprintf "Succeeded!\n"; flush stderr; tmpout @@ -2964,6 +2964,7 @@ let write_image pdf resources name image = close_out fh; (* If pnmtopng is present, convert the pnm to a PNG. *) begin match + (* FIXME: Use Filename.quote here *) Sys.command ("pnmtopng -gamma 0.45 -quiet " ^ "\"" ^ name ^ ".pnm\"" ^ "> \"" ^ name ^ ".png\" 2>" ^ null_device) with | 0 -> Sys.remove (name ^ ".pnm") @@ -3273,6 +3274,7 @@ let startends_of_range x = (* Calculating margins *) let calculate_margins filename pdf (s, e) = (* Call ghostscript *) + (* FIXME: Use Filename.quote here *) let gscall = args.path_to_ghostscript ^ " -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -r1200" @@ -4656,9 +4658,9 @@ let gs_malformed_force fi fo = exit 2 end; let gscall = - args.path_to_ghostscript ^ - " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ fo ^ - " -dBATCH " ^ fi + Filename.quote args.path_to_ghostscript ^ + " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ Filename.quote fo ^ + " -dBATCH " ^ Filename.quote fi in match Sys.command gscall with | 0 -> exit 0