backups: Allow valid filenames as archive names

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
James Valleroy 2018-07-08 18:59:29 -04:00 committed by Joseph Nuthalapati
parent c852cd824f
commit 4f6ed92286
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35
2 changed files with 9 additions and 5 deletions

View File

@ -19,12 +19,16 @@ Forms for backups module.
"""
from django import forms
from django.core import validators
from django.utils.translation import ugettext_lazy as _
class CreateArchiveForm(forms.Form):
name = forms.CharField(label=_('Archive name'), strip=True,
help_text=_('Name for new backup archive.'))
name = forms.CharField(
label=_('Archive name'), strip=True,
help_text=_('Name for new backup archive.'), validators=[
validators.RegexValidator(r'^[^/]+$', _('Invalid archive name'))
])
path = forms.CharField(label=_('Path'), strip=True, help_text=_(
'Disk path to a folder on this server that will be archived into '

View File

@ -26,10 +26,10 @@ from .views import IndexView, CreateArchiveView, DeleteArchiveView, \
urlpatterns = [
url(r'^sys/backups/$', IndexView.as_view(), name='index'),
url(r'^sys/backups/create/$', CreateArchiveView.as_view(), name='create'),
url(r'^sys/backups/(?P<name>[a-z0-9]+)/delete/$',
url(r'^sys/backups/(?P<name>[^/]+)/delete/$',
DeleteArchiveView.as_view(), name='delete'),
url(r'^sys/backups/(?P<name>[a-z0-9]+)/extract/$',
url(r'^sys/backups/(?P<name>[^/]+)/extract/$',
ExtractArchiveView.as_view(), name='extract'),
url(r'^sys/backups/(?P<name>[a-z0-9]+)/export/$',
url(r'^sys/backups/(?P<name>[^/]+)/export/$',
ExportArchiveView.as_view(), name='export'),
]