feat: sanitize all yaml #28

Merged
knoflook merged 3 commits from knoflook/lumbunglib:master into master 2022-04-12 11:44:35 +00:00
Showing only changes of commit 2fbc952a72 - Show all commits

View File

@ -5,7 +5,6 @@ from hashlib import md5
from ast import literal_eval as make_tuple
from pathlib import Path
from urllib.parse import urlparse
from re import sub
import arrow
import feedparser
@ -14,7 +13,8 @@ import requests
from bs4 import BeautifulSoup
from slugify import slugify
from re import compile as re_compile
yamlre = re_compile('"')
from re import sub
yamlre = re_compile('[_\?:\'\[\]\{\}\#\&\*\!\|\>\`\"\%]')
def write_etag(feed_name, feed_data):
@ -121,12 +121,12 @@ def sanitize_yaml (frontmatter):
#some fields are lists
l = []
for i in v:
i = yamlre.sub('\\"', i)
i = yamlre.sub(r'\\\g<0>', i)
l.append(i)
frontmatter[k] = l
else:
v = yamlre.sub('\\"', v)
v = yamlre.sub(r'\\\g<0>', v)
frontmatter[k] = v
return frontmatter