cubicweb #481437 FlotPlotView : crash if '&' appears in a label [deprecated]

I'm trying to build a plot with FlotPlotWidget, if the names list contains a '&' you get a crash:

XML Parsing Error: not well-formed
Location: http://127.0.0.1:8082/linearizedfunction/5037?vid=func_plot
Line Number 83, Column 50:jQuery.plot(jQuery("#figureA"), [{label: 'é&name2', data: figureA_0}],
---------------------------------------------------------------------^

The following patch prevents the crash, but the plot is not displayed:

diff -r 2e4794c97cf4 web/views/plots.py
--- a/web/views/plots.py        Thu Oct 15 12:10:48 2009 +0200
+++ b/web/views/plots.py        Thu Oct 15 21:41:29 2009 +0200
@@ -112,7 +112,7 @@
         for idx, (label, plot) in enumerate(zip(self.labels, self.plots)):
             plotid = '%s_%s' % (figid, idx)
             plotdefs.append('var %s = %s;' % (plotid, self.dump_plot(plot)))
-            plotdata.append("{label: '%s', data: %s}" % (label, plotid))
+            plotdata.append("{label: '%s', data: %s}" % (xml_escape(label), plotid))
         req.html_headers.add_onload(self.onload %
                                    {'plotdefs': '\n'.join(plotdefs),
                                     'figid': figid,

The following patch gets a plot (but mutilates the labels):

diff -r 4dd26ca635ed web/views/plots.py
--- a/web/views/plots.py        Fri Oct 16 08:14:34 2009 +0200
+++ b/web/views/plots.py        Fri Oct 16 09:53:11 2009 +0200
@@ -112,7 +112,7 @@
         for idx, (label, plot) in enumerate(zip(self.labels, self.plots)):
             plotid = '%s_%s' % (figid, idx)
             plotdefs.append('var %s = %s;' % (plotid, self.dump_plot(plot)))
-            plotdata.append("{label: '%s', data: %s}" % (label, plotid))
+            plotdata.append("{label: '%s', data: %s}" % (label.replace(u'&', u''), plotid))
         req.html_headers.add_onload(self.onload %
                                     {'plotdefs': '\n'.join(plotdefs),
                                      'figid': figid,
prioritynormal
typebug
done in<not specified>
load0.000
load left0.000
closed by<not specified>