-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added patch to sanitize external solver criteria.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/common/cudfSolver.ml b/common/cudfSolver.ml | ||
index 9bfda7e..548ee12 100644 | ||
--- a/common/cudfSolver.ml | ||
+++ b/common/cudfSolver.ml | ||
@@ -53,10 +53,14 @@ let rec input_all_lines acc chan = | ||
(** Solver "exec:" line. Contains three named wildcards to be interpolated: | ||
"$in", "$out", and "$pref"; corresponding to, respectively, input CUDF | ||
document, output CUDF universe, user preferences. *) | ||
+ | ||
+(* quote string for the shell, after removing all characters disallowed in criteria *) | ||
+let sanitize s = Printf.sprintf "\"%s\"" (Pcre.substitute ~rex:(Pcre.regexp "[^+()a-z,\"-]") ~subst:(fun _ -> "") s);; | ||
+ | ||
let interpolate_solver_pat exec cudf_in cudf_out pref = | ||
let _, exec = String.replace ~str:exec ~sub:"$in" ~by:cudf_in in | ||
let _, exec = String.replace ~str:exec ~sub:"$out" ~by:cudf_out in | ||
- let _, exec = String.replace ~str:exec ~sub:"$pref" ~by:pref in | ||
+ let _, exec = String.replace ~str:exec ~sub:"$pref" ~by:(sanitize pref) in | ||
exec | ||
;; | ||
|
||
diff --git a/common/cudfSolver.ml b/common/cudfSolver.ml | ||
index 548ee12..2caf76a 100644 | ||
--- a/common/cudfSolver.ml | ||
+++ b/common/cudfSolver.ml | ||
@@ -55,7 +55,7 @@ let rec input_all_lines acc chan = | ||
document, output CUDF universe, user preferences. *) | ||
|
||
(* quote string for the shell, after removing all characters disallowed in criteria *) | ||
-let sanitize s = Printf.sprintf "\"%s\"" (Pcre.substitute ~rex:(Pcre.regexp "[^+()a-z,\"-]") ~subst:(fun _ -> "") s);; | ||
+let sanitize s = Printf.sprintf "\"%s\"" (Re_pcre.substitute ~rex:(Re_pcre.regexp "[^+()a-z,\"-]") ~subst:(fun _ -> "") s);; | ||
|
||
let interpolate_solver_pat exec cudf_in cudf_out pref = | ||
let _, exec = String.replace ~str:exec ~sub:"$in" ~by:cudf_in in |