Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
monksy opened this issue Jan 31, 2024 · 2 comments
Open

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

monksy opened this issue Jan 31, 2024 · 2 comments

Comments

@monksy
Copy link

monksy commented Jan 31, 2024

"title" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}", \

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

@daattali
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants