--- a/__init__.py Thu Aug 09 23:47:58 2012 +0100
+++ b/__init__.py Fri Aug 10 22:41:36 2012 +0100
@@ -11,16 +11,19 @@
logging.basicConfig()
def filerevision_markdown(web, req, tmpl):
- f = req.form.get('file', [''])[0]
- parts = os.path.splitext(f)
+ path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0])
+ parts = os.path.splitext(path)
+
+ if not parts[1] == '.markdown' and not parts[1] == '.md':
+ return webcommands.file(web, req, tmpl)
- if not parts[1] == '.markdown' and not parts[1] == '.md':
- return rawfile(web, req, tmpl)
+ if not path:
+ return webcommands.file(web, req, tmpl)
previewMode = 'node' in req.form and req.form['node'][0] == '_preview'
if previewMode:
- text = file(web.repo.root + "/" + f).read()
+ text = file(web.repo.root + "/" + path).read()
else:
fctx = webutil.filectx(web.repo, req)
text = fctx.data()
@@ -32,9 +35,9 @@
md = markdown.Markdown(extensions=['wikilinks(base_url={0},end_url={1})'.format('', parts[1])])
html = md.convert(text)
- args = {'file':f,
+ args = {'file':path,
'readmefilename':parts[0].split('/')[-1],
- 'path':webutil.up(f),
+ 'path':webutil.up(path),
'readme':html}
if previewMode: