verbb / vizy

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

Using quotation marks in a Vizy field results in a JSON parse issue in the control panel #148

Closed jalendport closed 2 years ago

jalendport commented 2 years ago

Description Using straight quotes (") seems to cause a JSON parse issue in the CP. The field content saves initially, but it seems when Vizy tries to repopulate the field contents in the CP from the JSON in the DB, it converts the html entity into an actual quotation mark, and then tries to parse the JSON, which fails for obvious reasons. The CP is appearing exactly the same as #95, and this error shows up in the browser console: SyntaxError: Unexpected token T in JSON at position 210.

Here's the Vizy field's JSON straight from the DB:

[{
    "type": "heading",
    "attrs": {
        "textAlign": "start",
        "level": 4
    },
    "content": [{
        "type": "text",
        "text": "VIZY IS A GREAT FIELD"
    }]
}, {
    "type": "heading",
    "attrs": {
        "textAlign": "start",
        "level": 5
    },
    "content": [{
        "type": "text",
        "text": ""This is a great quote from someone not very famous.""
    }]
}]

My solution for now is to use curly quotes (“)...

Additional info

engram-design commented 2 years ago

Looks like we were incorrectly encoding quotes. These are properly skipped now, but I've also added handling to fix this error so you can continue to edit content.

Fixed for the next release. To get the fix early, change your verbb/vizy requirement in composer.json to:

"require": {
  "verbb/vizy": "dev-craft-3 as 1.0.14",
  "...": "..."
}

Then run composer update.

engram-design commented 2 years ago

Fixed in 1.0.15