Skip to content

Commit

Permalink
safely wrap title: contents using json dumps
Browse files Browse the repository at this point in the history
This should handle any arbitrary punctuation marks which may happen to
be in the Title - `",',\,*,...etc`.

I don't undersand why this works, since we're not doing anything with 
json. I just know that everything I've thrown at it comes out safely.

I left the change from pelican-plugins#15 intact, though json.dumps makes it 
unnecessary.
  • Loading branch information
maphew committed Feb 4, 2023
1 parent ad5aa9b commit 961375e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pelican/plugins/search/search.py
Expand Up @@ -9,6 +9,7 @@

from codecs import open
from inspect import cleandoc
from json import dumps
import logging
import os.path
from shutil import which
Expand All @@ -23,6 +24,7 @@

class SearchSettingsGenerator:
def __init__(self, context, settings, path, theme, output_path, *null):

self.output_path = output_path
self.context = context
self.content = settings.get("PATH")
Expand Down Expand Up @@ -74,7 +76,7 @@ def generate_output(self, writer):
[[input.files]]
path = "{page_to_index}"
url = "/{page.url}"
title = "{title}"
title = {dumps(striptags(page.title))}
"""
input_files = "".join([input_files, input_file])

Expand Down

0 comments on commit 961375e

Please sign in to comment.