diff options
author | spyinx <166288294+spyinx@users.noreply.github.com> | 2024-11-05 17:05:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-05 17:05:21 +0100 |
commit | 9cdd6e58b339317cc3dd17b0d5919eb6ee49f722 (patch) | |
tree | 88b74a21923eea82dd98817e3a56fd2f0e4f0281 | |
parent | Removed deprecated STRING_CONVERSION_ACTION (#84245) (diff) | |
download | ansible-9cdd6e58b339317cc3dd17b0d5919eb6ee49f722.tar.xz ansible-9cdd6e58b339317cc3dd17b0d5919eb6ee49f722.zip |
Fixed ipv6 pattern in parse_address (#84237)
-rw-r--r-- | changelogs/fragments/fix-ipv6-pattern.yml | 2 | ||||
-rw-r--r-- | lib/ansible/parsing/utils/addresses.py | 4 | ||||
-rw-r--r-- | test/units/parsing/utils/test_addresses.py | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/changelogs/fragments/fix-ipv6-pattern.yml b/changelogs/fragments/fix-ipv6-pattern.yml new file mode 100644 index 0000000000..48b1815052 --- /dev/null +++ b/changelogs/fragments/fix-ipv6-pattern.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix ipv6 pattern bug in lib/ansible/parsing/utils/addresses.py (https://github.com/ansible/ansible/issues/84237)
\ No newline at end of file diff --git a/lib/ansible/parsing/utils/addresses.py b/lib/ansible/parsing/utils/addresses.py index 33982d0485..5485c5f668 100644 --- a/lib/ansible/parsing/utils/addresses.py +++ b/lib/ansible/parsing/utils/addresses.py @@ -126,7 +126,7 @@ patterns = { 'ipv6': re.compile( r"""^ - (?:{0}:){{7}}{0}| # uncompressed: 1:2:3:4:5:6:7:8 + ((?:{0}:){{7}}{0}| # uncompressed: 1:2:3:4:5:6:7:8 (?:{0}:){{1,6}}:| # compressed variants, which are all (?:{0}:)(?::{0}){{1,6}}| # a::b for various lengths of a,b (?:{0}:){{2}}(?::{0}){{1,5}}| @@ -139,7 +139,7 @@ patterns = { # ipv4-in-ipv6 variants (?:0:){{6}}(?:{0}\.){{3}}{0}| ::(?:ffff:)?(?:{0}\.){{3}}{0}| - (?:0:){{5}}ffff:(?:{0}\.){{3}}{0} + (?:0:){{5}}ffff:(?:{0}\.){{3}}{0}) $ """.format(ipv6_component), re.X | re.I ), diff --git a/test/units/parsing/utils/test_addresses.py b/test/units/parsing/utils/test_addresses.py index 7562940dd8..4f94c8ab2c 100644 --- a/test/units/parsing/utils/test_addresses.py +++ b/test/units/parsing/utils/test_addresses.py @@ -34,6 +34,8 @@ class TestParseAddress(unittest.TestCase): '::ffff:1.2.3.4': ['::ffff:1.2.3.4', None], '::1.2.3.4': ['::1.2.3.4', None], '1234::': ['1234::', None], + # Invalid IPv6 address + '1234::9abc:def0:1234:5678:9abc::::::::def0': [None, None], # Hostnames 'some-host': ['some-host', None], |