[Checkins] SVN: zope3org/trunk/src/zorg/wikification/browser/wikilink.py Added support for . and .. in wiki links

Uwe Oestermeier uwe_oestermeier at iwm-kmrc.de
Mon Jun 12 07:02:15 EDT 2006


Log message for revision 68597:
  Added support for . and .. in wiki links

Changed:
  U   zope3org/trunk/src/zorg/wikification/browser/wikilink.py

-=-
Modified: zope3org/trunk/src/zorg/wikification/browser/wikilink.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-06-12 08:46:53 UTC (rev 68596)
+++ zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-06-12 11:02:15 UTC (rev 68597)
@@ -213,8 +213,13 @@
         while path :         
             try :
                 name = path[0]
-                name = unicode(name, encoding='utf-8')
-                node = self.traverseName(node, name)
+                if name == ".." :
+                    node = node.__parent__
+                elif name == "." :
+                    node = node
+                else :
+                    name = unicode(name, encoding='utf-8')
+                    node = self.traverseName(node, name)
                 name = path.pop(0)
             except (TraversalError, UnicodeEncodeError, UnicodeDecodeError) :
                 break
@@ -287,8 +292,10 @@
         
     def onRelativeLink(self, link) :
         """ Event handler that can be specialized. """
+        
         if self.base_url.endswith('/') :
             return self.base_url + link
+ 
         return "%s/%s" % (self.base_url, link)
         
         
@@ -366,6 +373,13 @@
         >>> processor.wikifyLink('http://127.0.0.1/site/folder')
         (False, 'http://127.0.0.1/site/folder/@@wiki.html')
         
+        The parser also handles '..' and '.' in URLs :
+        
+        >>> processor.wikifyLink('http://127.0.0.1/site/folder/../folder')
+        (False, 'http://127.0.0.1/site/folder/@@wiki.html')
+        >>> processor.wikifyLink('http://127.0.0.1/site/./folder')
+        (False, 'http://127.0.0.1/site/folder/@@wiki.html')
+        
         Relative and internal absolute links are treated the same. If 
         a link can be traversed successfully only the specific wiki
         view is added to ensure that we remain in the wiki navigation :
@@ -375,7 +389,7 @@
         >>> processor.wikifyLink('http://127.0.0.1/site/folder/emptysubfolder')
         (False, 'http://127.0.0.1/site/folder/emptysubfolder/@@wiki.html')
         
-        If the path cannot completely be resolved the link is changed to
+        If the path cannot be resolved completely the link is changed to
         an add view call :
         
         >>> processor.wikifyLink('http://127.0.0.1/site/folder/wikify.html')



More information about the Checkins mailing list