apache2-mod-proxy: better handling regexp extraction (#9609)
* apache2-mod-proxy: better handling regexp extraction * add changelog fragpull/9618/head
parent
a5d2e3ec80
commit
bf5c7f8be8
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- apache2_mod_proxy - better handling regexp extraction (https://github.com/ansible-collections/community.general/pull/9609).
|
|
@ -220,14 +220,14 @@ else:
|
|||
HAS_BEAUTIFULSOUP = True
|
||||
|
||||
# balancer member attributes extraction regexp:
|
||||
EXPRESSION = r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)"
|
||||
EXPRESSION = re.compile(r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)")
|
||||
# Apache2 server version extraction regexp:
|
||||
APACHE_VERSION_EXPRESSION = r"SERVER VERSION: APACHE/([\d.]+)"
|
||||
APACHE_VERSION_EXPRESSION = re.compile(r"SERVER VERSION: APACHE/([\d.]+)")
|
||||
|
||||
|
||||
def regexp_extraction(string, _regexp, groups=1):
|
||||
""" Returns the capture group (default=1) specified in the regexp, applied to the string """
|
||||
regexp_search = re.search(string=str(string), pattern=str(_regexp))
|
||||
regexp_search = _regexp.search(string)
|
||||
if regexp_search:
|
||||
if regexp_search.group(groups) != '':
|
||||
return str(regexp_search.group(groups))
|
||||
|
@ -251,7 +251,7 @@ class BalancerMember(object):
|
|||
"""
|
||||
|
||||
def __init__(self, management_url, balancer_url, module):
|
||||
self.host = regexp_extraction(management_url, str(EXPRESSION), 4)
|
||||
self.host = regexp_extraction(management_url, EXPRESSION, 4)
|
||||
self.management_url = str(management_url)
|
||||
self.protocol = regexp_extraction(management_url, EXPRESSION, 3)
|
||||
self.port = regexp_extraction(management_url, EXPRESSION, 5)
|
||||
|
|
Loading…
Reference in New Issue