[1.7.x] Refactored and commented strip_tags utility
Backport of c28beb4291
from master.
This commit is contained in:
parent
7b3a221ad6
commit
23984cf907
|
@ -161,15 +161,15 @@ def _strip_once(value):
|
||||||
|
|
||||||
def strip_tags(value):
|
def strip_tags(value):
|
||||||
"""Returns the given HTML with all tags stripped."""
|
"""Returns the given HTML with all tags stripped."""
|
||||||
while True:
|
# Note: in typical case this loop executes _strip_once once. Loop condition
|
||||||
if not ('<' in value or '>' in value):
|
# is redundant, but helps to reduce number of executions of _strip_once.
|
||||||
return value
|
while '<' in value and '>' in value:
|
||||||
new_value = _strip_once(value)
|
new_value = _strip_once(value)
|
||||||
if new_value == value:
|
if new_value == value:
|
||||||
# _strip_once was not able to detect more tags
|
# _strip_once was not able to detect more tags
|
||||||
return value
|
break
|
||||||
else:
|
value = new_value
|
||||||
value = new_value
|
return value
|
||||||
strip_tags = allow_lazy(strip_tags)
|
strip_tags = allow_lazy(strip_tags)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue