Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/4360.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Only send mail from contact-info on POST requests. @mauritsvanrees
6 changes: 6 additions & 0 deletions src/Products/CMFPlone/browser/contact_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def mailhost_is_configured(self):

@button.buttonAndHandler(_("label_send", default="Send"), name="send")
def handle_send(self, action):
if self.request.method != "POST":
# Only send on POST requests.
# See https://github.com/plone/Products.CMFPlone/issues/4360
self.success = False
return

data, errors = self.extractData()
if errors:
IStatusMessage(self.request).add(self.formErrorsMessage, type="error")
Expand Down
9 changes: 9 additions & 0 deletions src/Products/CMFPlone/tests/mails.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ lines ending in different spots:
>>> import quopri
>>> quopri.decodestring(msg).replace(b'\n', b' ')
b'...Another t\xc3\xa4st message...You are receiving this mail because T\xc3\xa4st user test@plone.test...is sending feedback about the site you administer at...'

We should only send an email on a POST request.
See https://github.com/plone/Products.CMFPlone/issues/4360

>>> browser.open('http://nohost/plone/contact-info?form.buttons.send=1&form.widgets.sender_fullname=Maurits&form.widgets.sender_from_address=maurits@example.com&form.widgets.subject=Hello&form.widgets.message=Bye')
>>> browser.url.startswith('http://nohost/plone/contact-info')
True
>>> 'A mail has now been sent' in browser.contents
False