From 05e0d314fd06bed7b658f97e12829eca9bf4f70a Mon Sep 17 00:00:00 2001 From: zhengxie Date: Wed, 3 Apr 2013 11:49:32 +0800 Subject: [PATCH] Quote url path --- group/views.py | 4 +++- views/file.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/group/views.py b/group/views.py index 1a4f36a536..47deaa46b5 100644 --- a/group/views.py +++ b/group/views.py @@ -14,6 +14,7 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404, \ from django.shortcuts import render_to_response, redirect from django.template import Context, loader, RequestContext from django.template.loader import render_to_string +from django.utils.encoding import smart_str from django.utils.hashcompat import md5_constructor from django.utils.http import urlquote from django.utils.translation import ugettext as _ @@ -1178,7 +1179,8 @@ def convert_wiki_link(content, group, repo_id, username): # convert other types of filelinks to clickable links path = "/" + linkname icon = file_icon_filter(linkname) - s = reverse('repo_view_file', args=[repo_id]) + '?p=' + path + s = reverse('repo_view_file', args=[repo_id]) + \ + '?p=' + urllib2.quote(smart_str(path)) a_tag = '''%s %s''' return a_tag % (MEDIA_URL, icon, icon, s, linkname) diff --git a/views/file.py b/views/file.py index 0b567d9e73..ec13c595f4 100644 --- a/views/file.py +++ b/views/file.py @@ -19,6 +19,7 @@ from django.http import HttpResponse, HttpResponseBadRequest, Http404, \ from django.shortcuts import render_to_response, redirect from django.template import Context, loader, RequestContext from django.template.loader import render_to_string +from django.utils.encoding import smart_str from django.utils.hashcompat import md5_constructor from django.utils.translation import ugettext as _ from seaserv import list_dir_by_path, get_repo, web_get_access_token, \ @@ -245,7 +246,8 @@ def convert_md_link(file_content, repo_id, username): # convert other types of filelinks to clickable links path = "/" + linkname icon = file_icon_filter(linkname) - s = reverse('repo_view_file', args=[repo_id]) + '?p=' + path + s = reverse('repo_view_file', args=[repo_id]) + \ + '?p=' + urllib2.quote(smart_str(path)) a_tag = '''%s %s''' return a_tag % (MEDIA_URL, icon, icon, s, linkname)