У пон, 28. 03 2011. у 15:24 +0000, Henning Eggers пише: > Review: Approve code > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi Danilo, > thanks for this important fix, I am sorry it took a bit longer to review it. > Also thanks for the discussion on IRC, I really enjoyed getting behind what > this code does (and I almost fully succeeded ... ;-) > > With the issues solved as discussed, this is good to land code-wise. Please > consider my other two suggestions below. > > review approve code > > Cheers, > Henning > > > Am 28.03.2011 13:22, schrieb Данило Шеган: > > === modified file 'lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py' > > --- lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py 2011-02-18 18:16:34 +0000 > > +++ lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py 2011-03-28 11:22:31 +0000 > > @@ -183,6 +183,15 @@ > > self.assertEqual( > > u"It's late.", self.subscription_filter.description) > > > > + def test_modify_description_xss_safeguard(self): > > + # The description can be modified. > > + > > + # Modify, save, and start a new transaction. > > Oops, something wrong with the comments here ... Fixed :) > > === modified file 'lib/lp/bugs/model/bugsubscriptionfilter.py' > > --- lib/lp/bugs/model/bugsubscriptionfilter.py 2011-03-22 14:53:26 +0000 > > +++ lib/lp/bugs/model/bugsubscriptionfilter.py 2011-03-28 11:22:31 +0000 > > @@ -62,7 +63,20 @@ > > > > other_parameters = Unicode() > > > > - description = Unicode() > > + _description = Unicode('description') > > + > > + def _get_description(self): > > + return self._description > > + > > + def _set_description(self, description): > > + if ('<' in description or '>' in description or > > + '"' in description or '&' in description): > > I don't like multi-line conditions. Can you please use an intermediate > variable? Ore would a regular expression be too expensive here? > re.find('[<>"&]', description), I think. I did consider using the re module (but for a very short while). It's not about multi-line for me though, but mostly about performance: this would do four passes over the string, and I suspect re would be even faster for long strings. However, with short strings (like descriptions will be), burden of loading the re module and compiling the expression is probably more than that. I'm happy to put it into an intermediate variable though, so I did that. > > === modified file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py' > > --- lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2011-03-21 18:20:09 +0000 > > +++ lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2011-03-28 11:22:31 +0000 > > @@ -70,6 +70,21 @@ > > self.assertEqual(u"foo", bug_subscription_filter.other_parameters) > > self.assertEqual(u"bar", bug_subscription_filter.description) > > > > + def test_description(self): > > + """Test the description property.""" > > + bug_subscription_filter = BugSubscriptionFilter() > > + bug_subscription_filter.description = u"foo" > > + self.assertEqual(u"foo", bug_subscription_filter.description) > > + > > + def test_description_xss_safeguard(self): > > + """description property disallows a few HTML characters.""" > > + bug_subscription_filter = BugSubscriptionFilter() > > + def set_description(filter, value): > > + filter.description = value > > + self.assertRaises(ValueError, > > + setattr, bug_subscription_filter, 'description', > > + u'