[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - HTTPResponse.py:1.75.2.5

Brian Lloyd brian at zope.com
Mon Jan 19 14:46:46 EST 2004


Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv13412/lib/python/ZPublisher

Modified Files:
      Tag: Zope-2_7-branch
	HTTPResponse.py 
Log Message:
apply missed 813 patches


=== Zope/lib/python/ZPublisher/HTTPResponse.py 1.75.2.4 => 1.75.2.5 ===
--- Zope/lib/python/ZPublisher/HTTPResponse.py:1.75.2.4	Thu Jan  8 18:34:01 2004
+++ Zope/lib/python/ZPublisher/HTTPResponse.py	Mon Jan 19 14:46:45 2004
@@ -22,6 +22,7 @@
 from zExceptions import Unauthorized, Redirect
 from zExceptions.ExceptionFormatter import format_exception
 from ZPublisher import BadRequest, InternalError, NotFound
+from cgi import escape
 
 nl2sp = maketrans('\n',' ')
 
@@ -461,7 +462,7 @@
                     ibase = base_re_search(body)
                     if ibase is None:
                         self.body = ('%s\n<base href="%s" />\n%s' %
-                                   (body[:index], self.quoteHTML(self.base),
+                                   (body[:index], escape(self.base, 1),
                                     body[index:]))
                         self.setHeader('content-length', len(self.body))
 
@@ -553,15 +554,9 @@
             return 1
         return 0
 
-    def quoteHTML(self,text,
-                  subs={'&':'&amp;', "<":'&lt;', ">":'&gt;', '\"':'&quot;'}
-                  ):
-        for ent in '&<>\"':
-            if text.find( ent) >= 0:
-                text = subs[ent].join(text.split(ent))
-
-        return text
-
+    # deprecated
+    def quoteHTML(self, text):
+        return escape(text, 1)
 
     def _traceback(self, t, v, tb, as_html=1):
         tb = format_exception(t, v, tb, as_html=as_html)
@@ -634,7 +629,7 @@
             "Resource not found",
             "Sorry, the requested resource does not exist." +
             "<p>Check the URL and try again.</p>" +
-            "<p><b>Resource:</b> %s</p>" % self.quoteHTML(entry))
+            "<p><b>Resource:</b> %s</p>" % escape(entry))
 
     forbiddenError = notFoundError  # If a resource is forbidden,
                                     # why reveal that it exists?




More information about the Zope-Checkins mailing list