[facet] fix 'bookmark this search': stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 31 Mar 2010 14:28:40 +0200
branchstable
changeset 5112 5bf8baecfaf8
parent 5111 9f3ea34f98d1
child 5113 f8cbdb51e6d4
[facet] fix 'bookmark this search': * vid wasn't included in the link generated by the facet box * proper url quoting in both js / box code (try an has_text search with '&' inside...)
web/data/cubicweb.facets.js
web/views/facets.py
--- a/web/data/cubicweb.facets.js	Wed Mar 31 14:27:02 2010 +0200
+++ b/web/data/cubicweb.facets.js	Wed Mar 31 14:28:40 2010 +0200
@@ -47,10 +47,11 @@
 	var rql = result[0];
 	var $bkLink = jQuery('#facetBkLink');
 	if ($bkLink.length) {
-	    var bkUrl = $bkLink.attr('cubicweb:target') + '&path=view?rql=' + rql;
+	    var bkPath = 'view?rql=' + escape(rql);
 	    if (vid) {
-		bkUrl += '&vid=' + vid;
+		bkPath += '&vid=' + escape(vid);
 	    }
+	    var bkUrl = $bkLink.attr('cubicweb:target') + '&path=' + escape(bkPath);
 	    $bkLink.attr('href', bkUrl);
 	}
 	var toupdate = result[1];
--- a/web/views/facets.py	Wed Mar 31 14:27:02 2010 +0200
+++ b/web/views/facets.py	Wed Mar 31 14:28:40 2010 +0200
@@ -105,7 +105,10 @@
     def display_bookmark_link(self, rset):
         eschema = self._cw.vreg.schema.eschema('Bookmark')
         if eschema.has_perm(self._cw, 'add'):
-            bk_path = 'view?rql=%s' % rset.printable_rql()
+            bk_path = 'rql=%s' % self._cw.url_quote(rset.printable_rql())
+            if self._cw.form.get('vid'):
+                bk_path += '&vid=%s' % self._cw.url_quote(self._cw.form['vid'])
+            bk_path = 'view?' + bk_path
             bk_title = self._cw._('my custom search')
             linkto = 'bookmarked_by:%s:subject' % self._cw.user.eid
             bk_add_url = self._cw.build_url('add/Bookmark', path=bk_path, title=bk_title, __linkto=linkto)