Chris McDonough
2011-09-08 d5dc5dd60e3bbff904a67dd02b4aff9226389942
add tests for high-order chars in path elements and filenames
3 files added
2 files modified
31 ■■■■■ changed files
CHANGES.txt 6 ●●●●● patch | view | raw | blame | history
pyramid/tests/fixtures/static/.hiddenfile 2 ●●●●● patch | view | raw | blame | history
pyramid/tests/fixtures/static/héhé.html 1 ●●●● patch | view | raw | blame | history
pyramid/tests/fixtures/static/héhé/index.html 1 ●●●● patch | view | raw | blame | history
pyramid/tests/test_integration.py 21 ●●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -8,6 +8,12 @@
  translations (``de``) would not work properly when using a localizer.  See
  https://github.com/Pylons/pyramid/issues/263
- The static file serving machinery could not serve files that started with a
  ``.`` (dot) character (hidden files).
- The static file serving machinery inappropriately URL-quoted path segments
  in filenames when asking for files from the filesystem.
Documentation
-------------
pyramid/tests/fixtures/static/.hiddenfile
New file
@@ -0,0 +1,2 @@
<html>I'm hidden</html>
pyramid/tests/fixtures/static/h?h?.html
New file
@@ -0,0 +1 @@
<html>hehe file</html>
pyramid/tests/fixtures/static/h?h?/index.html
New file
@@ -0,0 +1 @@
<html>hehe</html>
pyramid/tests/test_integration.py
@@ -70,6 +70,23 @@
        res = self.testapp.get('/minimal.pt', status=200)
        self._assertBody(res.body, os.path.join(here, 'fixtures/minimal.pt'))
    def test_hidden(self):
        res = self.testapp.get('/static/.hiddenfile', status=200)
        self._assertBody(res.body, os.path.join(here,
                                                'fixtures/static/.hiddenfile'))
    def test_highchars_in_pathelement(self):
        res = self.testapp.get('/static/h\xc3\xa9h\xc3\xa9/index.html',
                               status=200)
        self._assertBody(res.body, os.path.join(
            here, 'fixtures/static/h\xc3\xa9h\xc3\xa9/index.html'))
    def test_highchars_in_filename(self):
        res = self.testapp.get('/static/h\xc3\xa9h\xc3\xa9.html',
                               status=200)
        self._assertBody(res.body, os.path.join(
            here, 'fixtures/static/h\xc3\xa9h\xc3\xa9.html'))
    def test_not_modified(self):
        self.testapp.extra_environ = {
            'HTTP_IF_MODIFIED_SINCE':httpdate(pow(2, 32)-1)}
@@ -136,7 +153,9 @@
    def test_oob_slash(self):
        self.testapp.get('/%2F/test_integration.py', status=404)
        # XXX pdb this
    def test_oob_dotdotslash_encoded(self):
        self.testapp.get('/static/%2E%2E%2F/test_integration.py', status=404)
class TestStaticAppUsingAbsPath(TestStaticAppBase, unittest.TestCase):
    package = 'pyramid.tests.pkgs.static_abspath'