Skip to content

Commit

Permalink
Handle undefined values in form submission (#39)
Browse files Browse the repository at this point in the history
* Fix exceptions if frontend value is sent as `undefined`

* Try to fix test

* Comment my supposed fix

* format

* Remove comments

---------

Co-authored-by: Tiberiu Ichim <tiberiu.ichim@gmail.com>
  • Loading branch information
JeffersonBledsoe and tiberiuichim committed Jan 8, 2024
1 parent 7f781a1 commit 293cdd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def get_reply_to(self):
if field_id:
for data in self.form_data.get("data", ""):
if data.get("field_id", "") == field_id:
return data["value"]
return data.get("value", "")

return self.form_data.get("from", "") or self.block.get("default_from", "")

Expand Down Expand Up @@ -367,7 +367,7 @@ def attach_xml(self, msg):
for field in self.filter_parameters():
SubElement(
xmlRoot, "field", name=field.get("custom_field_id", field["label"])
).text = str(field["value"])
).text = str(field.get("value", ""))

doc = ElementTree(xmlRoot)
doc.write(output, encoding="utf-8", xml_declaration=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from plone.restapi.testing import RelativeSession
from Products.MailHost.interfaces import IMailHost
from six import StringIO
import xml.etree.ElementTree as ET
from zope.component import getUtility

import transaction
import unittest
import base64
import os
import transaction
import unittest
import xml.etree.ElementTree as ET


class TestMailSend(unittest.TestCase):
Expand Down

0 comments on commit 293cdd3

Please sign in to comment.