Skip to content
Permalink
Browse files

Fix #2684 -- prevent writing cache files outside of the cache folder

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Feb 25, 2017
1 parent ca1ab1b commit 937d93e56ece555c7f071d498a2ea763b46ec7ea
Showing with 5 additions and 0 deletions.
  1. +2 −0 CHANGES.txt
  2. +3 −0 nikola/post.py
@@ -18,6 +18,8 @@ Features
Bugfixes
--------

* Prevent writing cache files outside of the cache folder
(Issue #2684)
* Fix mimetype guessing in auto mode (Issue #2645)
* Fix filters.html5lib_xmllike for laters html5lib (Issue #2648)
* Skip the current post in post lists (Issue #2666)
@@ -118,6 +118,9 @@ def __init__(
self.pretty_urls = self.config['PRETTY_URLS']
self.source_path = source_path # posts/blah.txt
self.post_name = os.path.splitext(source_path)[0] # posts/blah
_relpath = os.path.relpath(self.post_name)
if _relpath != self.post_name:
self.post_name = _relpath.replace('..' + os.sep, '_..' + os.sep)
# cache[\/]posts[\/]blah.html
self.base_path = os.path.join(self.config['CACHE_FOLDER'], self.post_name + ".html")
# cache/posts/blah.html

0 comments on commit 937d93e

Please sign in to comment.