perbaikan validasi form untuk menghapus spasi pada input HTML

1 parent 35a33d96
...@@ -306,7 +306,7 @@ class BaseView(object): ...@@ -306,7 +306,7 @@ class BaseView(object):
"""Digunakan untuk memvalidasi form sebelum disubmit""" """Digunakan untuk memvalidasi form sebelum disubmit"""
exc = colander.Invalid(form, "Form tidak valid") exc = colander.Invalid(form, "Form tidak valid")
for k, v in value.items(): for k, v in value.items():
if v and self.html_tag_cleaner and isinstance(v, str) and v != "": if v and self.html_tag_cleaner and isinstance(v, str) and v.strip() != "":
try: try:
value[k] = lxml.html.fromstring(v).text_content() value[k] = lxml.html.fromstring(v).text_content()
except Exception as e: except Exception as e:
...@@ -964,7 +964,7 @@ class BaseView(object): ...@@ -964,7 +964,7 @@ class BaseView(object):
values.pop("id", None) values.pop("id", None)
self.ses["old_email"] = user and user.email or None self.ses["old_email"] = user and user.email or None
for k, v in values.items(): for k, v in values.items():
if v and self.html_tag_cleaner and isinstance(v, str) and v != "": if v and self.html_tag_cleaner and isinstance(v, str) and v.strip() != "":
try: try:
values[k] = lxml.html.fromstring(v).text_content() values[k] = lxml.html.fromstring(v).text_content()
except Exception as e: except Exception as e:
...@@ -1020,7 +1020,7 @@ class BaseView(object): ...@@ -1020,7 +1020,7 @@ class BaseView(object):
values[k] = v values[k] = v
for k, v in values.items(): for k, v in values.items():
if v and self.html_tag_cleaner and isinstance(v, str) and v != "": if v and self.html_tag_cleaner and isinstance(v, str) and v.strip() != "":
try: try:
values[k] = lxml.html.fromstring(v).text_content() values[k] = lxml.html.fromstring(v).text_content()
except Exception as e: except Exception as e:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!