1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #21959 -- Handled Inf/NaN in widthratio tag.

Thanks rmoe for the report and the patch.
This commit is contained in:
Aymeric Augustin
2014-02-08 21:00:43 +01:00
parent 5d263dee30
commit 07ae47f7f8
2 changed files with 4 additions and 2 deletions

View File

@@ -498,11 +498,11 @@ class WidthRatioNode(Node):
value = float(value)
max_value = float(max_value)
ratio = (value / max_value) * max_width
result = str(int(round(ratio)))
except ZeroDivisionError:
return '0'
except (ValueError, TypeError):
except (ValueError, TypeError, OverflowError):
return ''
result = str(int(round(ratio)))
if self.asvar:
context[self.asvar] = result