[CMF-checkins] CVS: CMF/CMFDefault - Link.py:1.11

Tres Seaver tseaver@zope.com
Wed, 14 Nov 2001 23:25:23 -0500


Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv26336/CMFDefault

Modified Files:
	Link.py 
Log Message:


  - Added fixup to Link objects for user-entered URLs which don't
    supply scheme:  for example, fix up 'www.zope.com' to
    'http://www.zope.com'.  (tracker #361)


=== CMF/CMFDefault/Link.py 1.10 => 1.11 ===
 ADD_CONTENT_PERMISSION = 'Add portal content'
 
-import Globals, string
+import Globals, string, urlparse
 from Globals import InitializeClass
 from AccessControl import ClassSecurityInfo
 from Products.CMFCore.PortalContent import PortalContent
@@ -180,7 +180,12 @@
         """
             Edit the Link
         """
-        self.remote_url=remote_url
+        tokens = urlparse.urlparse( remote_url, 'http' )
+        if tokens[0] and tokens[1]:
+            self.remote_url = urlparse.urlunparse( tokens )
+        else:
+            self.remote_url = 'http://' + remote_url
+
     edit = WorkflowAction(edit)
 
     security.declareProtected( CMFCorePermissions.View, 'SearchableText' )
@@ -201,7 +206,8 @@
 
         headers = {}
         headers, body = parseHeadersBody(body, headers)
-        self.edit(body)
+        lines = string.split( body, '\n' )
+        self.edit( lines[0] )
 
         headers['Format'] = 'text/url'
         new_subject = keywordsplitter(headers)