Explorar o código

sanitize dump file names (closes #3293)

Simon Krajewski %!s(int64=11) %!d(string=hai) anos
pai
achega
12b5dd3c55
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      codegen.ml

+ 5 - 0
codegen.ml

@@ -1307,12 +1307,17 @@ let rec constructor_side_effects e =
 		with Exit ->
 			true
 
+let make_valid_filename s =
+	let r = Str.regexp "[^A-Za-z0-9_\\-\\.,]" in
+	Str.global_substitute r (fun s -> "_") s
+
 (*
 	Make a dump of the full typed AST of all types
 *)
 let rec create_dumpfile acc = function
 	| [] -> assert false
 	| d :: [] ->
+		let d = make_valid_filename d in
 		let ch = open_out (String.concat "/" (List.rev (d :: acc)) ^ ".dump") in
 		let buf = Buffer.create 0 in
 		buf, (fun () ->