From ff7f9568dbbb8c62da8e20c6085e0cc241bbb9ab Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 11 Oct 2013 18:06:57 -0500 Subject: [PATCH] fixed validation of nagtive integers, thanks Stefan --- VERSION | 2 +- gluon/validators.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 042c8907..8fcb6fb5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.7.2-stable+timestamp.2013.10.11.17.58.33 +Version 2.7.2-stable+timestamp.2013.10.11.18.05.57 diff --git a/gluon/validators.py b/gluon/validators.py index ac955200..588847f5 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -22,6 +22,8 @@ from cStringIO import StringIO from gluon.utils import simple_hash, web2py_uuid, DIGEST_ALG_BY_SIZE from gluon.dal import FieldVirtual, FieldMethod +regex_isint = re.compile('^\-?\d+$') + JSONErrors = (NameError, TypeError, ValueError, AttributeError, KeyError) try: @@ -741,7 +743,7 @@ class IS_INT_IN_RANGE(Validator): % dict(min=self.minimum, max=self.maximum - 1) def __call__(self, value): - if value and str(value).isdigit(): + if value and regex_isint.match(str(value)): v = int(value) if ((self.minimum is None or v >= self.minimum) and (self.maximum is None or v < self.maximum)):