Skip to content

Commit

Permalink
Get rid of eval and fix #128 (#131)
Browse files Browse the repository at this point in the history
* Get rid of eval and fix #128

* format fixes by black
  • Loading branch information
dalito authored Apr 18, 2022
1 parent cde9d7c commit 9d8456b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ablog/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,11 @@ def apply(self):
if isinstance(tags, str):
# myst_parser store front-matter field to TextNode in dict_to_fm_field_list.
# like ["a", "b", "c"]
# remove [] and quote
try:
tags = eval(tags)
metadata["tags"] = ",".join(tags)
except Exception:
logging.warning(f"fail to eval tags: {tags}")
# remove [] and quotes
tags = tags.strip().lstrip("[").rstrip("]")
metadata["tags"] = ",".join(
[t.strip().lstrip('"').lstrip("'").rstrip('"').rstrip("'") for t in tags.split(",")]
)
if docinfo.traverse(nodes.author):
metadata["author"] = list(docinfo.traverse(nodes.author))[0].astext()
# These two fields are special-cased in docutils
Expand Down

0 comments on commit 9d8456b

Please sign in to comment.