[Pkg-libvirt-commits] [libguestfs] 30/59: v2v: -o libvirt: Minor refactoring of arch sanity check.

Hilko Bengen bengen at moszumanska.debian.org
Sun May 3 21:26:35 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit e3443a7549ce2643e50109de14148eeb0cfd0ce3
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Sat Apr 25 22:03:54 2015 +0100

    v2v: -o libvirt: Minor refactoring of arch sanity check.
---
 v2v/output_libvirt.ml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index db89f32..5be5b2c 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -30,7 +30,9 @@ module StringSet = Set.Make (String)
 let string_set_of_list =
   List.fold_left (fun set x -> StringSet.add x set) StringSet.empty
 
-let arch_sanity_re = Str.regexp "^[-_A-Za-z0-9]+$"
+let arch_is_sane_or_die =
+  let rex = Str.regexp "^[-_A-Za-z0-9]+$" in
+  fun arch -> assert (Str.string_match rex arch 0)
 
 let target_features_of_capabilities_doc doc arch =
   let xpathctx = Xml.xpath_new_context doc in
@@ -38,7 +40,7 @@ let target_features_of_capabilities_doc doc arch =
     (* Check the arch is sane.  It comes from untrusted input.  This
      * avoids XPath injection below.
      *)
-    assert (Str.string_match arch_sanity_re arch 0);
+    arch_is_sane_or_die arch;
     (* NB: Pay attention to the square brackets.  This returns the
      * <guest> nodes!
      *)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list