verbb / vizy

A flexible visual editor for Craft CMS
Other
43 stars 8 forks source link

Norwegian characters are not shown correctly #174

Closed torgeirbeyer closed 1 year ago

torgeirbeyer commented 1 year ago

Describe the bug

When updating from version 1.0.13 to 1.0.18 (or possibly other versions between), Norwegian characters are not encoded correctly.

Steps to reproduce

  1. Update plugin to 1.0.18
  2. Save an existing entry with a Vizy block with Norwegian characters æ, ø or å
  3. They are shown as seen in the attached screenshot Skjermbilde 2022-09-02 kl  10 41 47

Craft CMS version

3.7.42

Plugin version

1.0.18

Multi-site?

No

Additional context

It only happens to new entries or entries that have been updated, so I'm guessing it has something to do with how the content is stored in the database.

engram-design commented 1 year ago

I'm unable to replicate this, sorry.

image

This is indeed stored in the database as below:

[{"type":"paragraph","attrs":{"textAlign":"start"},"content":[{"type":"text","text":"æ, ø or å"}]}]

Which is correct - special characters and multibyte strings need to be encoded (think HTML characters to prevent injections). When rendered, these should be fine:

image

If you inspect the source, you'll note they contain the characters:

<p>&aelig;, &oslash; or &aring;</p>

Which are totally valid entities. Could also be related to https://github.com/verbb/vizy/issues/171

Can you show what your Twig template looks like and how you're rendering field content?

torgeirbeyer commented 1 year ago

Thanks for checking. We are using Next.js tor ender our frontend in this project, so might have to add some decoding there. Have the way data is stored in the databse changed with this update?

engram-design commented 1 year ago

There were some changes to how the content is stored in the database to address security concerns through XSS injections, so a change had to be made. You couldn't need to do any decoding on your front-end as those character codes (&aelig;) are valid when rendering in HTML.

torgeirbeyer commented 1 year ago

Thanks. Ill check it out once more and see if I find out anything.

torgeirbeyer commented 1 year ago

Checked some more, and we are using tiptap to render JSON and generateHTML-function in our Next.js-frontend application. So it might be some issues with tiptap not being able to render å, ø