diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-05-13 15:26:41 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-13 15:26:41 -0500 |
| commit | e1b570dfbdb5703688b445f9d54160754cc2d190 (patch) | |
| tree | 472544129bde5b05887b5626e41aae91416244d1 /src | |
| parent | 106be9f37dc69ff7f5e036550aff11dd96aa147e (diff) | |
| parent | 8835a91e8383319a6bb98de9fd400b4eb7883eb5 (diff) | |
| download | vyos1x-config-e1b570dfbdb5703688b445f9d54160754cc2d190.tar.gz vyos1x-config-e1b570dfbdb5703688b445f9d54160754cc2d190.zip | |
Merge pull request #43 from dmbaturin/T7450-use-pcre2
deps: T7450: use PCRE2 instead of the original, outdated PCRE
Diffstat (limited to 'src')
| -rw-r--r-- | src/config_file.ml | 4 | ||||
| -rw-r--r-- | src/dune | 2 | ||||
| -rw-r--r-- | src/reference_tree.ml | 2 | ||||
| -rw-r--r-- | src/util.ml | 4 | ||||
| -rw-r--r-- | src/value_checker.ml | 4 |
5 files changed, 8 insertions, 8 deletions
diff --git a/src/config_file.ml b/src/config_file.ml index 17d3f1b..d8dc8c9 100644 --- a/src/config_file.ml +++ b/src/config_file.ml @@ -1,7 +1,7 @@ (* strip commponent version string *) let strip_version s = - let rex = Pcre.regexp ~flags:[`MULTILINE;`DOTALL] "(^//.*)" in - let res = Pcre.split ~max:0 ~rex s in + let rex = Pcre2.regexp ~flags:[`MULTILINE;`DOTALL] "(^//.*)" in + let res = Pcre2.split ~max:0 ~rex s in match res with | h :: _ -> Ok h | [] -> Error "Failure stripping version string from config" @@ -6,7 +6,7 @@ (library (name vyos1x) (public_name vyos1x-config) - (libraries yojson menhirLib fileutils pcre xml-light unix containers) + (libraries yojson menhirLib fileutils pcre2 xml-light unix containers) (preprocess (pps ppx_deriving_yojson)) (foreign_stubs (language c) diff --git a/src/reference_tree.ml b/src/reference_tree.ml index d39cc96..63c6226 100644 --- a/src/reference_tree.ml +++ b/src/reference_tree.ml @@ -285,7 +285,7 @@ let has_illegal_characters name = All whitespace, curly braces, square brackets, and quotes are disallowed due to their special significance to the curly config format parser *) - try Some (Pcre.get_substring (Pcre.exec ~pat:"[\\s\\{\\}\\[\\]\"\'#]" name) 0) + try Some (Pcre2.get_substring (Pcre2.exec ~pat:"[\\s\\{\\}\\[\\]\"\'#]" name) 0) with Not_found -> None let format_out l = diff --git a/src/util.ml b/src/util.ml index 8fc5899..8ac7963 100644 --- a/src/util.ml +++ b/src/util.ml @@ -107,8 +107,8 @@ let json_of_list ss = let list_of_path p = let seg = String.trim p |> String.split_on_char '\'' in match seg with - | [h] -> Pcre.split ~pat:"\\s+" h - | h :: h' :: _ -> (Pcre.split ~pat:"\\s+" h) @ [h'] + | [h] -> Pcre2.split ~pat:"\\s+" h + | h :: h' :: _ -> (Pcre2.split ~pat:"\\s+" h) @ [h'] | _ -> [] diff --git a/src/value_checker.ml b/src/value_checker.ml index 9e6dae8..c066088 100644 --- a/src/value_checker.ml +++ b/src/value_checker.ml @@ -12,7 +12,7 @@ let validate_value dir buf value_constraint value = match value_constraint with | Regex s -> (try - let _ = Pcre.exec ~pat:(Printf.sprintf "^%s$" s) value in true + let _ = Pcre2.exec ~pat:(Printf.sprintf "^%s$" s) value in true with Not_found -> false) | External (v, c) -> (* XXX: Unix.open_process_in is "shelling out", which is a bad idea on multiple levels, @@ -23,7 +23,7 @@ let validate_value dir buf value_constraint value = let cmd = match c with | Some arg -> - let safe_arg = Printf.sprintf "%s" (Pcre.qreplace ~pat:"\"" ~templ:"\\\"" arg) in + let safe_arg = Printf.sprintf "%s" (Pcre2.qreplace ~pat:"\"" ~templ:"\\\"" arg) in Printf.sprintf "%s %s \'%s\' 2>&1" validator safe_arg value | None -> Printf.sprintf "%s \'%s\' 2>&1" validator value |
