Skip to content

Add honeypot field validation to newsletter form #1072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions assets/js/protocol/newsletter.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ const MzpNewsletter = {
const countrySelect = form.querySelector('select[name="country"]');
const lang = form.querySelector('#id_lang').value;
const terms = form.querySelector('input[name="terms"]');
// Note: 'office_fax' is the honeypot field name used by Bedrock/Springfield
// See: https://github.com/mozilla/bedrock/issues/16231
const honeypotField = form.querySelector('input[name="office_fax"]');
if (honeypotField && honeypotField.value.trim()) {
MzpNewsletter.handleFormError(
ERROR_LIST.NOT_FOUND
);
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this may in some cases prevent submission, I think it could be worth not only mentioning this honeypot addition in the changelog; but even finding a good place in the component docs or example descriptions to note there's now this special cased office_fax value being used for honeypot validation.


// Really basic client side email validity check.
if (!MzpNewsletter.checkEmailValidity(email)) {
Expand Down