Merge pull request #38566 from AarDG10/fix-user
fix(user): sanitize all html tags in name fields in User Doctype
This commit is contained in:
commit
4e52cbfb95
2 changed files with 5 additions and 2 deletions
|
|
@ -359,7 +359,7 @@ class User(Document):
|
|||
def clean_name(self):
|
||||
for field in ("first_name", "middle_name", "last_name"):
|
||||
if field_value := self.get(field):
|
||||
self.set(field, sanitize_html(field_value, always_sanitize=True))
|
||||
self.set(field, sanitize_html(field_value, always_sanitize=True, disallowed_tags="*"))
|
||||
|
||||
def set_full_name(self):
|
||||
self.full_name = " ".join(p for p in [self.first_name, self.middle_name, self.last_name] if p)
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ def sanitize_html(html, linkify=False, always_sanitize=False, disallowed_tags=No
|
|||
|
||||
# Allow caller to explicitly disallow some tags
|
||||
if disallowed_tags:
|
||||
if disallowed_tags == "*":
|
||||
tags = set()
|
||||
else:
|
||||
tags.difference_update(disallowed_tags)
|
||||
|
||||
attributes = {"*": acceptable_attributes, "svg": svg_attributes}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue