diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-05-13 15:27:22 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-13 15:27:22 -0500 |
| commit | 176163e5a6911e88ca790e503ed501d5aceaff34 (patch) | |
| tree | 314fd8c7b29de28ef063e1686c0b877047359686 /src/validate_value.ml | |
| parent | 08e0d27887d073dc4b8e452af0a137cd8d30a7ac (diff) | |
| parent | c6cb5ce2724a52b3b7b3741323c4466c87953c6a (diff) | |
| download | vyos-utils-176163e5a6911e88ca790e503ed501d5aceaff34.tar.gz vyos-utils-176163e5a6911e88ca790e503ed501d5aceaff34.zip | |
Merge pull request #33 from dmbaturin/T7450-use-pcre2
validators: T7450: use PCRE2 instead of the outdated original PCRE
Diffstat (limited to 'src/validate_value.ml')
| -rw-r--r-- | src/validate_value.ml | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/validate_value.ml b/src/validate_value.ml index 05d62b1..fd9f3d9 100644 --- a/src/validate_value.ml +++ b/src/validate_value.ml @@ -12,14 +12,16 @@ let rec validate_value buf value_constraint value = | Group l -> List.for_all (fun c -> validate_value buf c value) l | Regex s -> - (try let _ = Pcre.exec ~pat:(Printf.sprintf "^%s$" s) value in true + (try let _ = Pcre2.exec ~pat:(Printf.sprintf "^%s$" s) value in true with Not_found -> false) | Exec c -> (* XXX: Unix.open_process_in is "shelling out", which is a bad idea on multiple levels, especially when the input comes directly from the user... We should do something about it. *) - let chan = Unix.open_process_in (Printf.sprintf "%s \'%s\' 2>&1" c value) in + let cmd = Printf.sprintf "%s \'%s\' 2>&1" c value in + let () = Printf.printf "COMMAND: %s" cmd in + let chan = Unix.open_process_in cmd in let out = try CCIO.read_all chan with _ -> "" in let result = Unix.close_process_in chan in match result with |
