diff MoinMoin/formatter/text_html.py @ 143:11df1156d432

fixed MoinMoinBugs/BrokenAttachmentPaths imported from: moin--main--1.5--patch-145
author Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
date Thu, 27 Oct 2005 09:15:20 +0000
parents 67f71c7a8c43
children 99bf20eeb0bc
line wrap: on
line diff
--- a/MoinMoin/formatter/text_html.py	Thu Oct 27 02:00:48 2005 +0000
+++ b/MoinMoin/formatter/text_html.py	Thu Oct 27 09:15:20 2005 +0000
@@ -301,8 +301,8 @@
 
     def attachment_link(self, url, text, **kw):
         _ = self.request.getText
-        pagename = self.page.page_name
-        fname = wikiutil.taintfilename(url)
+        pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
+        fname = wikiutil.taintfilename(filename)
         fpath = AttachFile.getFilename(self.request, pagename, fname)
         if not os.path.exists(fpath):
             linktext = _('Upload new attachment "%(filename)s"')
@@ -312,15 +312,15 @@
                           (wikiutil.quoteWikinameURL(pagename),
                            wikiutil.url_quote_plus(fname))),
                 linktext % {'filename': self.text(fname)})
-        target = AttachFile.getAttachUrl(pagename, url, self.request)
+        target = AttachFile.getAttachUrl(pagename, filename, self.request)
         return (self.url(1, target, title="attachment:%s" % url) +
                 self.text(text) +
                 self.url(0))
     
     def attachment_image(self, url, **kw):
         _ = self.request.getText
-        pagename = self.page.page_name
-        fname = wikiutil.taintfilename(url)
+        pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
+        fname = wikiutil.taintfilename(filename)
         fpath = AttachFile.getFilename(self.request, pagename, fname)
         if not os.path.exists(fpath):
             linktext = _('Upload new attachment "%(filename)s"')
@@ -332,23 +332,23 @@
                 linktext % {'filename': self.text(fname)})
         return self.image(
             title="attachment:%s" % url,
-            src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1))
+            src=AttachFile.getAttachUrl(pagename, filename, self.request, addts=1))
     
     def attachment_drawing(self, url, text, **kw):
         _ = self.request.getText
-        pagename = self.page.page_name
-        fname = wikiutil.taintfilename(url)
+        pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
+        fname = wikiutil.taintfilename(filename)
         drawing = fname
         fname = fname + ".png"
-        url = url + ".png"
+        filename = filename + ".png"
         # fallback for old gif drawings (1.1 -> 1.2)
         fpath = AttachFile.getFilename(self.request, pagename, fname)
         if not os.path.exists(fpath):
             gfname = fname[:-4] + ".gif"
-            gurl = url[:-4] + ".gif"
+            gfilename = filename[:-4] + ".gif"
             gfpath = AttachFile.getFilename(self.request, pagename, gfname)
             if os.path.exists(gfpath):
-                fname, url, fpath = gfname, gurl, gfpath
+                fname, filename, fpath = gfname, gfilename, gfpath
 
         # check whether attachment exists, possibly point to upload form
         if not os.path.exists(fpath):
@@ -389,23 +389,23 @@
                 return (map + self.image(
                     alt=drawing,
                     src=AttachFile.getAttachUrl(
-                    pagename, url, self.request,
+                    pagename, filename, self.request,
                     addts=1),
                     usemap='#'+mapid, html_class="drawing"))
         else:
             return wikiutil.link_tag(self.request,
                                      edit_link,
                                      self.image(alt=url,
-                                                src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1), html_class="drawing"),
+                                                src=AttachFile.getAttachUrl(pagename, filename, self.request, addts=1), html_class="drawing"),
                                      attrs='title="%s"' % (_('Edit drawing %(filename)s') % {'filename': self.text(fname)}))
         
     
     def attachment_inlined(self, url, text, **kw):
         _ = self.request.getText
-        pagename = self.page.page_name
-        fname = wikiutil.taintfilename(url)
+        pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
+        fname = wikiutil.taintfilename(filename)
         fpath = AttachFile.getFilename(self.request, pagename, fname)
-        base, ext = os.path.splitext(url)
+        base, ext = os.path.splitext(filename)
         Parser = wikiutil.getParserForExtension(self.request.cfg, ext)
         if Parser is not None:
             try: