wanze / SeoMaestro

🧙‍♂️A ProcessWire module helping you to manage SEO related tasks like a boss.
MIT License
34 stars 9 forks source link

SeoDataBase encode issue #15

Closed flihub closed 4 years ago

flihub commented 4 years ago

using v1.0 and ENT_XML1 with entities1 broke Turkish character "ü".

convert "Tüm" to "Tüm" and browser not propery display.

https://github.com/wanze/SeoMaestro/blob/7e3c9b4fa89b9a8284d4aede5db350ead510b2e0/src/SeoDataBase.php#L230

changed this line to return $sanitizer->entities1($value, ENT_QUOTES); problem resolved.

php v7.2.19

tiefenb commented 4 years ago

This issue came also up on our side

Bildschirmfoto 2019-11-28 um 21 03 25
tiefenb commented 4 years ago

In our case, removing ENT_XML1 "Mario Käppeli" became "Mario Käppeli".

So there is some double encoding on this field?!

tiefenb commented 4 years ago

I guess the problem is, that umlauts are saved as entities in the db. So in the first step we should decode this entities?

I have tested this and it works:

protected function encode($value)
    {
        $sanitizer = $this->wire('sanitizer');

        $value = $sanitizer->text($value, ['maxLength' => 0]);
        $value = $sanitizer->unentities($value);
        $value = $sanitizer->entities1($value, ENT_QUOTES | ENT_XML1);

        return $value;
    }
gebeer commented 4 years ago

I can confirm this error. @tiefenb 's solution works for me with german umlauts. Ü becomes Ü

wanze commented 4 years ago

Fixed with 1.0.1: https://github.com/wanze/SeoMaestro/releases/tag/v1.0.1