[Zope-Checkins] SVN: Zope/branches/2.9/ - Fixup usage of urljoin in webdav.davcmds

Sidnei da Silva sidnei at enfoldsystems.com
Thu Jul 20 08:22:37 EDT 2006


Log message for revision 69225:
  
  - Fixup usage of urljoin in webdav.davcmds
  (a shame I missed the deadline to Zope 2.9.4)
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/webdav/common.py
  U   Zope/branches/2.9/lib/python/webdav/davcmds.py

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.9/doc/CHANGES.txt	2006-07-20 12:09:12 UTC (rev 69224)
+++ Zope/branches/2.9/doc/CHANGES.txt	2006-07-20 12:22:36 UTC (rev 69225)
@@ -14,6 +14,13 @@
      to the rules for such a type laid out in the Python docs:
      http://docs.python.org/api/supporting-cycle-detection.html
 
+  Zope 2.9.5 (unreleased)
+
+   Bugs fixed
+
+      - Usage of 'urljoin' in 'webdav.davcmds' could lead to wrongly
+        constructed urls.
+
   Zope 2.9.4 (2006/07/21)
 
    Bugs fixed

Modified: Zope/branches/2.9/lib/python/webdav/common.py
===================================================================
--- Zope/branches/2.9/lib/python/webdav/common.py	2006-07-20 12:09:12 UTC (rev 69224)
+++ Zope/branches/2.9/lib/python/webdav/common.py	2006-07-20 12:22:36 UTC (rev 69225)
@@ -42,6 +42,11 @@
         return attr()
     return attr
 
+def urljoin(url, s):
+    url = url.rstrip('/')
+    s = s.lstrip('/')
+    return '/'.join((url, s))
+
 def urlfix(url, s):
     n=len(s)
     if url[-n:]==s: url=url[:-n]

Modified: Zope/branches/2.9/lib/python/webdav/davcmds.py
===================================================================
--- Zope/branches/2.9/lib/python/webdav/davcmds.py	2006-07-20 12:09:12 UTC (rev 69224)
+++ Zope/branches/2.9/lib/python/webdav/davcmds.py	2006-07-20 12:22:36 UTC (rev 69225)
@@ -23,10 +23,9 @@
 from AccessControl import getSecurityManager
 from Acquisition import aq_parent
 from OFS.PropertySheets import DAVProperties
-from ZConfig.url import urljoin
 from zExceptions import BadRequest, Forbidden
 
-from common import absattr, aq_base, urlfix, urlbase
+from common import absattr, aq_base, urlfix, urlbase, urljoin
 from common import isDavCollection
 from common import PreconditionFailed
 from interfaces import IWriteLock
@@ -170,8 +169,8 @@
                     if dflag:
                         ob._p_deactivate()
                 elif hasattr(ob, '__dav_resource__'):
-                    uri=urljoin(url, absattr(ob.id))
-                    depth=depth=='infinity' and depth or 0
+                    uri = urljoin(url, absattr(ob.getId()))
+                    depth = depth=='infinity' and depth or 0
                     self.apply(ob, uri, depth, result, top=0)
                     if dflag:
                         ob._p_deactivate()
@@ -409,7 +408,7 @@
         if depth == 'infinity' and iscol:
             for ob in obj.objectValues():
                 if hasattr(obj, '__dav_resource__'):
-                    uri = urljoin(url, absattr(ob.id))
+                    uri = urljoin(url, absattr(ob.getId()))
                     self.apply(ob, creator, depth, token, result,
                                uri, top=0)
         if not top:
@@ -474,7 +473,7 @@
                 if hasattr(ob, '__dav_resource__') and \
                         (IWriteLock.providedBy(ob) or
                          WriteLockInterface.isImplementedBy(ob)):
-                    uri = urljoin(url, absattr(ob.id))
+                    uri = urljoin(url, absattr(ob.getId()))
                     self.apply(ob, token, uri, result, top=0)
         if not top:
             return result
@@ -529,7 +528,7 @@
             for ob in obj.objectValues():
                 dflag = hasattr(ob,'_p_changed') and (ob._p_changed == None)
                 if hasattr(ob, '__dav_resource__'):
-                    uri = urljoin(url, absattr(ob.id))
+                    uri = urljoin(url, absattr(ob.getId()))
                     self.apply(ob, token, user, uri, result, top=0)
                     if dflag:
                         ob._p_deactivate()



More information about the Zope-Checkins mailing list