Uniform - Special characters encoding

This weekend I used uniform and it works great, bu when I receive a message containing spécial chars like & or " they are encoded like in html. I dont know how to avoid this. I want to send plain text messages, I dont kow if I have to set an option for this.

example message:
Test de "caractères spéciaux" é & accentués 'youpi' became
Test de "caractères spéciaux" é & accentués 'youpi'

Maybe @mzur have an idea!

Edit: also, a problem in the csrf form give a “hard” error (via whoops) and break the page, how can I display a nice message instead?

Thank you!

That’s actually a problem, thanks for pointing that out. A quick workaround would be to use this email snippet instead:

<?php

unset($data['email']);
unset($data['receive_copy']);
$body = '';
foreach ($data as $key => $value) {
    if (is_array($value)) {
        $value = implode(', ', array_filter($value, function ($i) {
            return $i !== '';
        }));
    }
    $body .= ucfirst($key).': '.htmlspecialchars_decode($value)."\n\n";
}

echo $body;

I’ve opened an issue about this at jevets/kirby-form.

Yes, I already thought about disabling the errors if Kirby is not in debug mode. You can always catch the error like so:

<?php

use Uniform\Form;
use Uniform\Exceptions\TokenMismatchException;

return function ($site, $pages, $page) {

    $form = new Form([/*...*/]);

    $tokenMismatch = false;

    if (r::is('POST')) {
        try {
            $form->emailAction([/*...*/]);
        } catch (TokenMismatchException $e) {
            $tokenMismatch = true;
        }
    }

    return compact('form', 'tokenMismatch');
};

Thank you, I will try the email snippet tomorrow.

The issue should be resolved in the current master branch of Uniform (and with the next release). Please give it a try and report back if everything works :wink: