hopefully correctly fix the breadcrumbs escaping 3.5
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 11 Sep 2009 12:40:27 +0200
branch3.5
changeset 3176 b94703b131ad
parent 3173 6f9da29f836a
child 3177 e7ae807554d9
hopefully correctly fix the breadcrumbs escaping
web/test/data/bootstrap_cubes
web/test/unittest_breadcrumbs.py
web/test/unittest_form.py
web/views/ibreadcrumbs.py
--- a/web/test/data/bootstrap_cubes	Thu Sep 10 18:49:23 2009 +0200
+++ b/web/test/data/bootstrap_cubes	Fri Sep 11 12:40:27 2009 +0200
@@ -1,1 +1,1 @@
-file, blog, tag
+file, blog, tag, folder
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/unittest_breadcrumbs.py	Fri Sep 11 12:40:27 2009 +0200
@@ -0,0 +1,17 @@
+from cubicweb.devtools.testlib import WebTest
+
+class BreadCrumbsTC(WebTest):
+
+    def test_base(self):
+        f1 = self.add_entity('Folder', name=u'par&ent')
+        f2 = self.add_entity('Folder', name=u'chi&ld')
+        self.execute('SET F2 filed_under F1 WHERE F1 eid %(f1)s, F2 eid %(f2)s',
+                     {'f1' : f1.eid, 'f2' : f2.eid})
+        self.commit()
+        childrset = self.execute('Folder F WHERE F eid %s' % f2.eid)
+        self.assertEquals(childrset.get_entity(0,0).view('breadcrumbs'),
+                          '<a href="http://testing.fr/cubicweb/folder/715" title="">chi&amp;ld</a>')
+        ibc = self.vreg['components'].select('breadcrumbs', self.request(), rset=childrset)
+        self.assertEquals(ibc.render(),
+                          """<span id="breadcrumbs" class="pathbar">&#160;&gt;&#160;<a href="http://testing.fr/cubicweb/Folder">folder_plural</a>&#160;&gt;&#160;<a href="http://testing.fr/cubicweb/folder/714" title="">par&amp;ent</a>&#160;&gt;&#160;
+chi&amp;ld</span>""")
--- a/web/test/unittest_form.py	Thu Sep 10 18:49:23 2009 +0200
+++ b/web/test/unittest_form.py	Fri Sep 11 12:40:27 2009 +0200
@@ -54,6 +54,7 @@
         unrelated = [reid for rview, reid in form2.object_relation_vocabulary('tags')]
         self.failIf(t.eid in unrelated, unrelated)
 
+
     def test_form_field_vocabulary_new_entity(self):
         e = self.etype_instance('CWUser')
         form = EntityFieldsForm(self.request(), None, entity=e)
--- a/web/views/ibreadcrumbs.py	Thu Sep 10 18:49:23 2009 +0200
+++ b/web/views/ibreadcrumbs.py	Fri Sep 11 12:40:27 2009 +0200
@@ -56,9 +56,9 @@
     def wpath_part(self, part, contextentity, last=False):
         if isinstance(part, Entity):
             if last and part.eid == contextentity.eid:
-                part.view('breadcrumbtext', w=self.w)
+                self.w(xml_escape(part.view('breadcrumbtext')))
             else:
-                part.view('breadcrumbs', w=self.w)
+                self.w(part.view('breadcrumbs'))
         elif isinstance(part, tuple):
             url, title = part
             textsize = self.req.property_value('navigation.short-line-size')
@@ -99,8 +99,9 @@
     def cell_call(self, row, col):
         entity = self.rset.get_entity(row, col)
         desc = xml_escape(uilib.cut(entity.dc_description(), 50))
-        self.w(tags.a(entity.view('breadcrumbtext'), href=entity.absolute_url(),
-                      title=desc))
+        # XXX remember camember : tags.a autoescapes !
+        self.w(tags.a(entity.view('breadcrumbtext'),
+                      href=entity.absolute_url(), title=desc))
 
 
 class BreadCrumbTextView(EntityView):
@@ -109,4 +110,4 @@
     def cell_call(self, row, col):
         entity = self.rset.get_entity(row, col)
         textsize = self.req.property_value('navigation.short-line-size')
-        self.w(xml_escape(uilib.cut(entity.dc_title(), textsize)))
+        self.w(uilib.cut(entity.dc_title(), textsize))