Special characters breaking blueprint content in the panel

In a field I’m building I save data like this:

-
  seo-title: Some title
  seo-description: Some description

It works fine in most cases. Sometimes I got an error with > (larger than) and adding : (colon) does not go so well.

Because this content is generated by javascript I can escape some characters before they are saved.

My question is… Are there any other characters that I should escape to prevent errors? If you have another approach, let’s hear that as well.

Just tested some cases with http://yaml-online-parser.appspot.com/ and this seems to work:

-
  seo-title: >-
    Seo title with : colon
  seo-description: >-
    Seo description with "some" cite 'and' > larger characters

Pitfalls or alternatives are still helpful.

With http://yaml-online-parser.appspot.com/ it validates perfectly fine.

In a blueprint it trows a notice:

Notice: Undefined offset: 5 in C:\wamp\www\seo\kirby\toolkit\vendors\yaml\yaml.php on line 508

Seo: 

-
  seo-title: >-
    åäö llasdas
  seo-description: >-
    rwerwe wer ewrerte : fsd >

Is it a Kirby bug? It’s the last “larger than” character that causes it. It seems like the problem only appear when the “larger than” character is last in the row.

1 Like

Well, even easier: Always wrap the result in quotes and escape any quotes you have in the values:

-
  seo-title: "Some title with \"Quotes\""
  seo-description: "Some description"

You won’t need to escape any other characters.

2 Likes

I’ll probably go for that one. Shorter and looks better.

…and is more robust. :wink:

1 Like

Yes. That’s the most important thing. Forgot to mension it. :slight_smile:

Hi,
using this topic since I have a similar issue. Suddenly on every panel page appears an error notice:
Notice: Undefined offset: 63 in /kirby/toolkit/vendors/yaml/yaml.php on line 508

It could be a special character issue because it didn’t appear until now and I didn’t change anything in the vendors or kirby files, but how can I know what produces the error?

Thanks,

Are you using the same blueprint on every page?
Could you share that blueprint ?

I don’t know what else could cause this but some issues with spacing in your yaml files. Maybe somebody has got a better idea ?

1 Like

Ok, I didn’t know it was related to the blueprint. I re-wrote it and the error disappeared, must have been a spacing issue indeed. Thanks!

Yeah YAML can be pesky when it come to spacing.

Best tip: don’t use tabs, use actual spaces.
If your text editor allows it, show spaces when editing the file so you can see errors as you go :wink: