mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-29 12:09:37 +00:00
sharing: Allow double quotes in path strings
Unix paths can contain double quotes. Allow entering paths with double quotes by escaping them in c-style[1] and retrieve them back properly. 1) https://httpd.apache.org/docs/2.4/expr.html Tests: Run tests on with various paths: - /var/a b - /var/c"d - /var/ef" Run the following tests. - Create a directory with the test path and create a sample file inside it. - Add a share with the test path. - Ensure that the share is accessible and the file can be downloaded. - Ensure that the list of the shares shows the path correctly. - Ensure that the share can be edited. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
0b2125aad6
commit
59d7721682
@ -57,7 +57,7 @@ def load_augeas():
|
||||
def subcommand_add(arguments):
|
||||
"""Add a share to Apache configuration."""
|
||||
name = arguments.name
|
||||
path = '"' + arguments.path + '"'
|
||||
path = '"' + arguments.path.replace('"', r'\"') + '"'
|
||||
groups = arguments.groups
|
||||
is_public = arguments.is_public
|
||||
url = '/share/' + name
|
||||
@ -150,11 +150,13 @@ def _list(aug=None):
|
||||
url = aug.get(match + '/arg[1]')
|
||||
path = aug.get(match + '/arg[2]')
|
||||
|
||||
path = path.removesuffix('"').removeprefix('"')
|
||||
path = path.replace(r'\"', '"')
|
||||
try:
|
||||
name = _get_name_from_url(url)
|
||||
shares.append({
|
||||
'name': name,
|
||||
'path': path.strip('"'),
|
||||
'path': path,
|
||||
'url': '/share/' + name
|
||||
})
|
||||
except ValueError:
|
||||
|
||||
@ -20,9 +20,8 @@ class AddShareForm(forms.Form):
|
||||
'A lowercase alpha-numeric string that uniquely identifies a '
|
||||
'share. Example: <em>media</em>.'))
|
||||
|
||||
path = forms.RegexField(
|
||||
label=_('Path to share'), strip=True, regex=r'^[^\"]+$',
|
||||
help_text=_(
|
||||
path = forms.CharField(
|
||||
label=_('Path to share'), strip=True, help_text=_(
|
||||
'Disk path to a folder on this server that you intend to share.'))
|
||||
|
||||
is_public = forms.BooleanField(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user