From 63b755f85afb12ae6b609d76ef7d1b4cc2ff5a98 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 18 Aug 2021 09:06:10 +0200 Subject: policy: T2425: import exact Perl match criteria for large-community-list --- src/validators/large-community-list | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/validators/large-community-list b/src/validators/large-community-list index 6c9a3a148..c07268e81 100755 --- a/src/validators/large-community-list +++ b/src/validators/large-community-list @@ -29,13 +29,8 @@ if __name__ == '__main__': if not len(value) == 3: sys.exit(1) - # Check if the first string is an IPv4 address - if is_ipv4(value[0]): - if value[1].isdigit() and value[2].isdigit(): - sys.exit(0) - # If first string is not an IP address it must be a number - else: - if value[0].isdigit() and value[1].isdigit() and value[2].isdigit(): - sys.exit(0) + if not (re.match(pattern, sys.argv[1]) and + (is_ipv4(value[0]) or value[0].isdigit()) and value[1].isdigit()): + sys.exit(1) - sys.exit(1) + sys.exit(0) -- cgit v1.2.3