[web/component] guard against invalid page_size form parameter
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 05 Jan 2016 10:36:17 +0100
changeset 11082 0cdd92261c4a
parent 11081 70733b2dfd2a
child 11083 4b18b1027d02
[web/component] guard against invalid page_size form parameter Same as dff28956f37e, except the almost same code exists in two places (yay us).
web/component.py
--- a/web/component.py	Tue Jan 05 10:31:29 2016 +0100
+++ b/web/component.py	Tue Jan 05 10:36:17 2016 +0100
@@ -71,10 +71,13 @@
         except AttributeError:
             page_size = self.cw_extra_kwargs.get('page_size')
             if page_size is None:
-                if 'page_size' in self._cw.form:
-                    page_size = int(self._cw.form['page_size'])
-                else:
-                    page_size = self._cw.property_value(self.page_size_property)
+                try:
+                    page_size = int(self._cw.form.get('page_size'))
+                except (ValueError, TypeError):
+                    # no or invalid value, fall back
+                    pass
+            if page_size is None:
+                page_size = self._cw.property_value(self.page_size_property)
             self._page_size = page_size
             return page_size