diff options
| author | Tomasz Wysocki <tomasz@pozytywnie.pl> | 2014-04-03 08:59:06 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2014-04-03 21:28:10 +0200 |
| commit | 23984cf907168d2a26579e54bf53d5d222431f01 (patch) | |
| tree | d5cfc8440711e437e37273bba8e1ffa38e3168cb | |
| parent | 7b3a221ad674ce74afd5db2a7dd0a0a3beb354ed (diff) | |
[1.7.x] Refactored and commented strip_tags utility
Backport of c28beb4291 from master.
| -rw-r--r-- | django/utils/html.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/django/utils/html.py b/django/utils/html.py index a3de585707..79488fc473 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -161,15 +161,15 @@ def _strip_once(value): def strip_tags(value): """Returns the given HTML with all tags stripped.""" - while True: - if not ('<' in value or '>' in value): - return value + # Note: in typical case this loop executes _strip_once once. Loop condition + # is redundant, but helps to reduce number of executions of _strip_once. + while '<' in value and '>' in value: new_value = _strip_once(value) if new_value == value: # _strip_once was not able to detect more tags - return value - else: - value = new_value + break + value = new_value + return value strip_tags = allow_lazy(strip_tags) |
