gridftp: handle paths beginning with `~`
[qcg-portal.git] / filex / forms.py
index 26ca737..e9b866f 100644 (file)
@@ -12,12 +12,12 @@ from filex.models import Favorite
 msg = u'Invalid value'
 host_validator = RegexValidator(r'^(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+'
                                 r'(?:[a-zA-Z]{2,6}\.?|[a-zA-Z0-9-]{2,}(?<!-)\.?))(?::\d+)?$', msg)
-path_validator = RegexValidator(r'^/(?:[^/\0]+/?)*$', msg)
+path_validator = RegexValidator(r'^~?(?:/[^/\0]*)*$', msg)
 name_validator = RegexValidator(r'^[^/\0]+$', msg)
 
 
 def clean_path(path):
-    return urlquote(os.path.normpath(path))
+    return urlquote(os.path.normpath(path), safe='/~')
 
 
 class FavoriteForm(forms.ModelForm):