beautiful-jekyll icon indicating copy to clipboard operation
beautiful-jekyll copied to clipboard

[BUG] Search JSON doesn't escape back slashes and breaks search

Open monksy opened this issue 5 months ago • 2 comments

https://github.com/daattali/beautiful-jekyll/blob/e5ababbfb57c0dbf5dae997c60271b4ccee6fed8/_includes/search.html#L14

This should be able to escape back slashes in the title. Since it doesn't, this creates invalid json and breaks the parsing:

Example:

  {
    "title": "Today I learned: Use %n rather than \n in String.format",
    "category": "",
    "url": "/blog2/2013/11/27/today-i-learned-use-n-rather-than-n-in-string-format/",
    "date": "November 27, 2013"
  },

Produces: SyntaxError: JSON.parse: bad control character in string literal

monksy avatar Jan 31 '24 04:01 monksy

Thanks for the report. I'm surprised by this bug, because the title does get escaped. Most other characters seem to be correctly escaped, but it looks like a backslash needs to be escaped manually with another backslash (using \\ works fine according to my test). Do you agree this looks like a bug with the escape filter in jekyll/Liquid template, rather than a bug in the theme?

daattali avatar Mar 12 '24 21:03 daattali

@monksy are you able to test to see whether this is a bug resulting from this theme or not?

daattali avatar Apr 20 '24 18:04 daattali