Allow removing non-alnum chars from volid

This mimics similar change in lorax.

JIRA: RCM-36970
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-07-26 14:52:19 -04:00
parent 10bdb370ba
commit add9835b56
4 changed files with 52 additions and 0 deletions

View file

@ -392,8 +392,14 @@ def get_volid(compose, arch, variant=None, escape_spaces=False, disc_type=False,
raise ValueError("Could not create volume ID longer than 32 bytes, options are %r",
sorted(tried, key=len))
if compose.conf["restricted_volid"]:
# Replace all non-alphanumeric characters and non-underscores) with
# dashes.
volid = re.sub(r"\W", "-", volid, flags=re.I)
if volid and escape_spaces:
volid = volid.replace(" ", r"\x20")
return volid