Skip to content
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

Add protections against spams and a configuration page. #19

Merged
merged 2 commits into from
Mar 26, 2018
Merged

Add protections against spams and a configuration page. #19

merged 2 commits into from
Mar 26, 2018

Conversation

alegout
Copy link
Contributor

@alegout alegout commented Mar 22, 2018

Add protections against spams and a configuration page.

Ticket: BOOM-4288

QA: Needs to be tested with 1.7.2 and 1.7.3. Wordings will have to stay in English until 1.7.4

Trololo

Add protections against spams and a configuration page.
contactform.php Outdated

$message = $this->trans(
'For even more security on your website forms, consult our Security & Access modules category on the %s',
array($this->getSecurityMarketPlaceLink()),
Copy link
Member

@Quetzacoalt91 Quetzacoalt91 Mar 23, 2018

Choose a reason for hiding this comment

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

Don't you want to add placeholders like in the core? Like
'%link%' => array($this->getSecurityMarketPlaceLink()),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

totally, thanks :)

contactform.php Outdated

if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from)) {
$this->context->controller->errors[] = $this->trans('Invalid email address.', array(), 'Shop.Notifications.Error');
} elseif (preg_match('#^[ ]*$#', $message)) {
} elseif (!$message) {
Copy link
Member

@Quetzacoalt91 Quetzacoalt91 Mar 23, 2018

Choose a reason for hiding this comment

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

It seems a message filled with blanks could pass now, should not we test that with a trim() and empty()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

go for empty 👍

contactform.php Outdated
{

$message = $this->trans(
'For even more security on your website forms, consult our Security & Access modules category on the %s',
Copy link
Member

Choose a reason for hiding this comment

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

Maybe change "website" to "shop's"?
ping @LouiseBonnard @colinegin

contactform.php Outdated
array(
'type' => 'switch',
'label' => $this->trans('Send confirmation email to your customers', array(), 'Modules.Contactform.Admin'),
'desc' => $this->trans('Click Yes and your customers will receive a confirmation email without the message content', array(), 'Modules.Contactform.Admin'),
Copy link
Member

Choose a reason for hiding this comment

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

I think this wording could be improved to better guide the merchants:

Choose Yes and your customers will receive a generic confirmation email including a tracking number after their message is sent. Note: to discourage spam, the content of their message won't be included in the email.

What do you think @LouiseBonnard @colinegin ?

Choose a reason for hiding this comment

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

Ah oui !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

contactform.php Outdated
$lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->submit_action = 'update-configuration';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='
Copy link
Member

Choose a reason for hiding this comment

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

You should use parse_url() to make sure that there's a query string in the URL returned by $this->context->link->getAdminLink('AdminModules', false), then http_build_query() to rebuild the query string with your arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

contactform.php Outdated
} elseif ($url !== '' || empty($serverToken)
|| $clientToken !== $serverToken || $clientTokenTTL < time()
) {
$this->context->controller->errors[] = $this->trans('An error occurred while sending the message.', array(), 'Modules.Contactform.Shop');
Copy link
Member

Choose a reason for hiding this comment

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

How about adding a "Please try again"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

contactform.php Outdated
@@ -176,14 +375,17 @@ public function sendMessage()
$this->context->controller->errors[] = $this->trans('An error occurred during the file-upload process.', array(), 'Modules.Contactform.Shop');
} elseif (!empty($file_attachment['name']) && !in_array(Tools::strtolower(substr($file_attachment['name'], -4)), $extension) && !in_array(Tools::strtolower(substr($file_attachment['name'], -5)), $extension)) {
$this->context->controller->errors[] = $this->trans('Bad file extension', array(), 'Modules.Contactform.Shop');
} elseif ($url !== '' || empty($serverToken)
|| $clientToken !== $serverToken || $clientTokenTTL < time()
Copy link
Member

Choose a reason for hiding this comment

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

Either one line for all statements or one statement per line please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Fix issues, code refacto

Fix issues, code refacto

Fix issues, code refacto

Fix issues

Fix issues, code refacto

Fix blank line

Remove extra space

Update translation
@eternoendless
Copy link
Member

Thank you @alegout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants