1

The problem is when user submit the form with special characters in the contact form (description field), in the mail it converts to HTML characters. After lot of debugging I nailed down the following file.

\vendor\magento\module-contact\view\adminhtml\email\submitted_form.html

the file contains

{{trans "Name: %name" name=$data.name}}
{{trans "Email: %email" email=$data.email}}
{{trans "Phone Number: %telephone" telephone=$data.telephone}}

{{trans "Comment: %comment" comment=$data.comment}}

I tried wrapping up %comment/$data.comment field with htmlspecialchars/ htmlentities functions. but it's not working.

For example, If I entered the following word (Hello' world") in the contact form, I receive as

Hello' world"

1 Answer 1

0

You need to restrict the special character's using javascript in form element.

var valid = (e.which >= 48 && e.which <= 57) || (e.which >= 65 && e.which <= 90) || (e.which >= 97 && e.which <= 122); if (!valid) { e.preventDefault(); }

2
  • Thanks for your time, but adding restriction to the contact form; I don't think it's ideal. Because adding more constraint, they may easily quit the task. It mean we loose customers; besides the problem is in our end.
    – FR STAR
    Dec 4, 2016 at 11:50
  • Without htmlentities(), the textarea would interpret and display the contact form php.net/manual/en/function.htmlentities.php
    – karthick
    Dec 4, 2016 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.