From f73cf2b3eb9ce1ce8c642765a2caa95e2aa646e6 Mon Sep 17 00:00:00 2001 From: Doug Weimer Date: Thu, 23 Feb 2012 05:50:36 +0000 Subject: [PATCH] Add support for URLs and absolute paths in staticweb CSS listings. Fixes bug 939267. Return the quoted web-listings-css value if it starts with '/', 'http://', or 'https://.' All other values are treated as relative paths. Change-Id: I55ee4ec77cf8db99aa48c9a398e29767b200e1eb --- swift/common/middleware/staticweb.py | 16 ++++- test/unit/common/middleware/test_staticweb.py | 60 +++++++++++++++++-- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/swift/common/middleware/staticweb.py b/swift/common/middleware/staticweb.py index bd799a8743..9638514da8 100644 --- a/swift/common/middleware/staticweb.py +++ b/swift/common/middleware/staticweb.py @@ -307,8 +307,7 @@ class StaticWeb(object): cgi.escape(env['PATH_INFO']) if self._listings_css: body += ' \n' % \ - ('../' * prefix.count('/'), quote(self._listings_css)) + 'href="%s" />\n' % (self._build_css_path(prefix)) else: body += ' ' not in resp.body) self.assert_('