1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-07-03 10:05:41 +00:00

Compare commits

...

2 commits

Author SHA1 Message Date
catborise
fe550317d2
Merge pull request #561 from weidongkl/master
enhancement: optimize regular expressions
2022-12-26 09:09:32 +03:00
weidong
1be57f987e enhancement: optimize regular expressions 2022-12-26 11:42:14 +08:00

View file

@ -38,9 +38,7 @@ class AddStgPool(forms.Form):
def clean_target(self):
storage_type = self.cleaned_data["stg_type"]
target = self.cleaned_data["target"]
have_symbol = re.match("^[^-][a-zA-Z0-9/_-]+$", target) and not re.match(
".*/-", target
)
have_symbol = re.match("^[^-](\/?((?:[0-9a-zA-Z_])|(?:\.)|((?<!\/)-))*)+$", target)
if storage_type in ["dir", "netfs"] and not have_symbol:
raise forms.ValidationError(
_("The target must not contain any special characters")