👋 Next.js Conf 2024: Come build, party, run, and connect with us! See all events

Junk characters in presentation mode due to stega encoding

8 replies
Last updated: Jun 6, 2024
In presentation mode only some of my fields have a lot of junk characters. Any idea what’s going on? I’ve seen this on multiple projects now.
Jun 5, 2024, 5:37 PM
This comes from presentation - it's the stega encoding. This could happen if you copy from the website into the sanity studio, but I believe we've implemented a filter for this to strip stega from the clipboard.
Jun 5, 2024, 6:39 PM
This could happen if you copy from the website into the sanity studio
What do you mean exactly?
Jun 5, 2024, 6:41 PM
For some more context, this breaks some of my code. For example, I do an equality check on a select option value and the equality check is always false due to these characters.

// schema 

defineField({
      title: 'Game',
      name: 'game',
      type: 'string',
      options: {
        list: [
          { title: 'Scarlet & Violet', value: 'scarlet-violet' },
          { title: 'Sword & Shield', value: 'sword-shield' },
        ],
      },
    }), 
This is always false, because data.game has all the strange characters (
scarlet-violet��‌‌​‌​​‍‌​‍​​​‌‌‍‌‌​‌‍​​​‌​​‌‌​‍‌‌‍​‌​‌‍‌‍​​​​‍‌‌​‌‍‌‌​​‌‍‌‌​‌‌‍​‌‌‌‌‌‌​‌‍‍​‌‍‌​‍​‍‌​​‌‍​‌‌‌​‌‍‍​​‌‌‍‍‌‍​‌‌‍‌‌‍‌‌​‌‍​‍‌‍​‌‌​‌‍‌‌‌‌‌‌‌​‍‌‍​​‌​‍‌‌​​‍‌​‌‍‌​‌‌​‌‌‌‌‍‌​‌‍‍‌‌‍​‍‌‍‌‍‍‌‌‍‌​​‌​​‍​​​​​​‌‌‌‍‌‌​​​‌‍‌‍​‍​‍‌‌‍‌‍​‍‌​‌​​‍​‍‌​‌​​​​‍‌‌‍​‍​‍‌‌‍​‍​‍​​‌‌​‌​​‍‌​‍​​​‌‌‍‌‌​‌‍​​​‌​​‌‌​‍‌‌‍​‌​‌‍‌‍​​​​‍‌‍‌‌​‌‍‌‌​​‌‍‌‌​‌‌‍​‌‌‌‌‌‌​‌‍‍​‌‍‌​‍​‍‌‍‌​​‌‍​‌‌‌​‌‍‍​​‌‌‍‍‌‍​‌‌‍‌‌‍‌‌​‍​‍‌‌��‌‌​‌​​‍‌​‍​​​‌‌‍‌‌​‌‍​​​‌​​‌‌​‍‌‌‍​‌​‌‍‌‍​​​​‍‌‌​‌‍‌‌​​‌‍‌‌​‌‌‍​‌‌‌‌‌‌​‌‍‍​‌‍‌​‍​‍‌​​‌‍​‌‌‌​‌‍‍​​‌‌‍‍‌‍​‌‌‍‌‌‍‌‌​‌‍​‍‌‍​‌‌​‌‍‌‌‌‌‌‌‌​‍‌‍​​‌​‍‌‌​​‍‌​‌‍‌​‌‌​‌‌‌‌‍‌​‌‍‍‌‌‍​‍‌‍‌‍‍‌‌‍‌​​‌​​‍​​​​​​‌‌‌‍‌‌​​​‌‍‌‍​‍​‍‌‌‍‌‍​‍‌​‌​​‍​‍‌​‌​​​​‍‌‌‍​‍​‍‌‌‍​‍​‍​​‌‌​‌​​‍‌​‍​​​‌‌‍‌‌​‌‍​​​‌​​‌‌​‍‌‌‍​‌​‌‍‌‍​​​​‍‌‍‌‌​‌‍‌‌​​‌‍‌‌​‌‌‍​‌‌‌‌‌‌​‌‍‍​‌‍‌​‍​‍‌‍‌​​‌‍​‌‌‌​‌‍‍​​‌‌‍‍‌‍​‌‌‍‌‌‍‌‌​‍​‍‌‌

// my component

const isScarlet = data.game === 'scarlet-violet'
Jun 5, 2024, 6:45 PM
So I’m seeing these characters on more than just text inputs, but enumerated select options too.
Jun 5, 2024, 6:46 PM
Sorry about that - I thought this was appearing right off the API and that your strings had this data already embedded in it. This is stega encoding and it saves you the trouble of having to encode source maps in data attributes yourself. https://www.sanity.io/docs/stega If you want strict equality though you will need to strip Stega first.
Jun 5, 2024, 6:49 PM
This docs page is exactly what I needed. Thank you!!!
Jun 5, 2024, 6:51 PM
👍
Jun 6, 2024, 1:14 PM
We're of two minds about Stega - it saves times, but leads to some of these 🤔 situations where it leaks through before it's been properly explained
Jun 6, 2024, 1:15 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?