• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

allura


Commit MetaInfo

修訂eff488577636f9406db8fec9e6992cb2d5d96b0a (tree)
時間2012-05-15 00:02:36
作者Cory Johns <johnsca@geek...>
CommiterYaroslav Luzin

Log Message

[#4193] Fixed unicode and quoting issue in attachments and added tests

Signed-off-by: Cory Johns <johnsca@geek.net>

Change Summary

差異

--- a/Allura/allura/controllers/attachments.py
+++ b/Allura/allura/controllers/attachments.py
@@ -51,7 +51,7 @@ class AttachmentController(BaseController):
5151 if attachment is None:
5252 raise exc.HTTPNotFound
5353 return attachment
54-
54+
5555 @expose()
5656 def index(self, delete=False, **kw):
5757 if request.method == 'POST':
@@ -64,8 +64,8 @@ class AttachmentController(BaseController):
6464 except exc.HTTPNotFound:
6565 pass
6666 redirect(request.referer)
67- return self.attachment.serve(False)
67+ return self.attachment.serve(embed=False)
6868
6969 @expose()
70- def thumb(self, embed=True):
71- return self.thumbnail.serve(embed)
70+ def thumb(self):
71+ return self.thumbnail.serve(embed=True)
--- a/Allura/allura/model/filesystem.py
+++ b/Allura/allura/model/filesystem.py
@@ -94,7 +94,7 @@ class File(MappedClass):
9494 if not embed:
9595 pylons.response.headers.add(
9696 'Content-Disposition',
97- 'attachment;filename=%s' % self.filename)
97+ 'attachment;filename="%s"' % self.filename.encode('utf-8'))
9898 return iter(fp)
9999
100100 @classmethod
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -125,7 +125,7 @@ class TestAttachment(TestController):
125125 for f in thread.html.findAll('form'):
126126 if f.get('action', '').endswith('/post'):
127127 break
128- self.post_form_link = f['action'].encode('utf-8')
128+ self.post_form_link = f['action'].encode('utf-8')
129129 params = dict()
130130 inputs = f.findAll('input')
131131 for field in inputs:
@@ -148,6 +148,7 @@ class TestAttachment(TestController):
148148 else:
149149 assert False, 'attachment link not found'
150150 r = self.app.get(alink)
151+ assert r.content_disposition == 'attachment;filename="test.txt"', 'Attachments should force download'
151152 r = self.app.post(self.post_link + 'attach',
152153 upload_files=[('file_info', 'test.o12', 'HiThere!')])
153154 r = self.app.post(alink, params=dict(delete='on'))
--- a/Allura/allura/tests/model/test_filesystem.py
+++ b/Allura/allura/tests/model/test_filesystem.py
@@ -100,7 +100,7 @@ class TestFile(TestCase):
100100 self._assert_content(f, 'test2')
101101
102102 def test_serve(self):
103- f = File.from_data('test1.txt', 'test1')
103+ f = File.from_data(u'te s\u0b6e1.txt', 'test1')
104104 self.session.flush()
105105 assert [ 'test1' ] == list(f.serve())
106106 assert response.content_type == f.content_type
@@ -108,7 +108,7 @@ class TestFile(TestCase):
108108 assert [ 'test1' ] == list(f.serve(False))
109109 assert response.content_type == f.content_type
110110 assert response.headers['Content-Disposition'] == \
111- 'attachment;filename=test1.txt'
111+ 'attachment;filename="te s\xe0\xad\xae1.txt"'
112112
113113 def test_image(self):
114114 path = os.path.join(