More use of Filename.quote

This commit is contained in:
John Whitington 2019-08-18 15:22:13 +01:00
parent a18d268919
commit 418983df7f
2 changed files with 14 additions and 12 deletions

View File

@ -70,7 +70,7 @@ let find_cpdflin provided =
of the cpdflin binary. Returns the exit code. *) of the cpdflin binary. Returns the exit code. *)
let call_cpdflin cpdflin temp output best_password = let call_cpdflin cpdflin temp output best_password =
let command = let command =
cpdflin ^ " --linearize " ^ " --password=" ^ best_password ^ " " ^ Filename.quote cpdflin ^ " --linearize " ^ " --password=" ^ best_password ^ " " ^
Filename.quote temp ^ " " ^ Filename.quote output Filename.quote temp ^ " " ^ Filename.quote output
in in
match Sys.os_type with match Sys.os_type with
@ -87,8 +87,8 @@ let call_cpdflin cpdflin temp output best_password =
Sys.command command Sys.command command
| _ -> | _ ->
let command = let command =
"DYLD_FALLBACK_LIBRARY_PATH=" ^ Filename.dirname cpdflin ^ " " ^ "DYLD_FALLBACK_LIBRARY_PATH=" ^ Filename.quote (Filename.dirname cpdflin) ^ " " ^
"LD_LIBRARY_PATH=" ^ Filename.dirname cpdflin ^ " " ^ "LD_LIBRARY_PATH=" ^ Filename.quote (Filename.dirname cpdflin) ^ " " ^
command command
in in
if !debug then prerr_endline command; if !debug then prerr_endline command;

View File

@ -2346,9 +2346,9 @@ let embed_missing_fonts fi fo =
exit 2 exit 2
end; end;
let gscall = let gscall =
args.path_to_ghostscript ^ Filename.quote args.path_to_ghostscript ^
" -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ fo ^ " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ Filename.quote fo ^
" -dBATCH " ^ fi " -dBATCH " ^ Filename.quote fi
in in
match Sys.command gscall with match Sys.command gscall with
| 0 -> exit 0 | 0 -> exit 0
@ -2365,9 +2365,9 @@ let mend_pdf_file_with_ghostscript filename =
let tmpout = Filename.temp_file "cpdf" ".pdf" in let tmpout = Filename.temp_file "cpdf" ".pdf" in
tempfiles := tmpout::!tempfiles; tempfiles := tmpout::!tempfiles;
let gscall = let gscall =
args.path_to_ghostscript ^ Filename.quote args.path_to_ghostscript ^
" -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ tmpout ^ " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ Filename.quote tmpout ^
" -dBATCH " ^ filename " -dBATCH " ^ Filename.quote filename
in in
match Sys.command gscall with match Sys.command gscall with
| 0 -> Printf.eprintf "Succeeded!\n"; flush stderr; tmpout | 0 -> Printf.eprintf "Succeeded!\n"; flush stderr; tmpout
@ -2964,6 +2964,7 @@ let write_image pdf resources name image =
close_out fh; close_out fh;
(* If pnmtopng is present, convert the pnm to a PNG. *) (* If pnmtopng is present, convert the pnm to a PNG. *)
begin match begin match
(* FIXME: Use Filename.quote here *)
Sys.command ("pnmtopng -gamma 0.45 -quiet " ^ "\"" ^ name ^ ".pnm\"" ^ "> \"" ^ name ^ ".png\" 2>" ^ null_device) Sys.command ("pnmtopng -gamma 0.45 -quiet " ^ "\"" ^ name ^ ".pnm\"" ^ "> \"" ^ name ^ ".png\" 2>" ^ null_device)
with with
| 0 -> Sys.remove (name ^ ".pnm") | 0 -> Sys.remove (name ^ ".pnm")
@ -3273,6 +3274,7 @@ let startends_of_range x =
(* Calculating margins *) (* Calculating margins *)
let calculate_margins filename pdf (s, e) = let calculate_margins filename pdf (s, e) =
(* Call ghostscript *) (* Call ghostscript *)
(* FIXME: Use Filename.quote here *)
let gscall = let gscall =
args.path_to_ghostscript ^ args.path_to_ghostscript ^
" -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -r1200" " -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -r1200"
@ -4656,9 +4658,9 @@ let gs_malformed_force fi fo =
exit 2 exit 2
end; end;
let gscall = let gscall =
args.path_to_ghostscript ^ Filename.quote args.path_to_ghostscript ^
" -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ fo ^ " -dNOPAUSE " ^ (if args.gs_quiet then "-dQUIET" else "") ^ " -sDEVICE=pdfwrite -sOUTPUTFILE=" ^ Filename.quote fo ^
" -dBATCH " ^ fi " -dBATCH " ^ Filename.quote fi
in in
match Sys.command gscall with match Sys.command gscall with
| 0 -> exit 0 | 0 -> exit 0