Correctly store apostrophies in the posts.py storage

This commit is contained in:
deadvey 2025-04-01 19:30:55 +01:00
parent ff79fdd2a7
commit aa3ae147bf
2 changed files with 7 additions and 4 deletions

View File

@ -29,11 +29,15 @@ Content: {posts.posts[post_to_edit_index]['content']}
answer = input() answer = input()
if answer == "0" or answer == "T": # Editing the title if answer == "0" or answer == "T": # Editing the title
posts.posts[post_to_edit_index]['title'] = click.edit(posts.posts[post_to_edit_index]['title']) title = click.edit(posts.posts[post_to_edit_index]['title'])
title = title.replace("'", "\'")
posts.posts[post_to_edit_index]['title'] = title
posts.posts[post_to_edit_index]['editdate'] = datetime.now().strftime("%d%m%YZ%H%M%ST") posts.posts[post_to_edit_index]['editdate'] = datetime.now().strftime("%d%m%YZ%H%M%ST")
elif answer == "1" or answer == "C": # Editing the content elif answer == "1" or answer == "C": # Editing the content
posts.posts[post_to_edit_index]['content'] = click.edit(posts.posts[post_to_edit_index]['content']) content = click.edit(posts.posts[post_to_edit_index]['content'])
content = content.replace("'", "\'")
posts.posts[post_to_edit_index]['content'] = content
posts.posts[post_to_edit_index]['editdate'] = datetime.now().strftime("%d%m%YZ%H%M%ST") posts.posts[post_to_edit_index]['editdate'] = datetime.now().strftime("%d%m%YZ%H%M%ST")
elif answer == "2" or answer == "D": # Editing the existence elif answer == "2" or answer == "D": # Editing the existence

View File

@ -18,8 +18,7 @@ import output
def newpost(userID, username, datetime): def newpost(userID, username, datetime):
title = input("Title: ") title = input("Title: ")
content = click.edit() content = click.edit()
content = content.replace("'", "&#39") content = content.replace("'", "\'")
content = content.replace("\n", "\n")
output.log(content) output.log(content)
datetime = datetime.now().strftime("%d%m%YZ%H%M%ST") datetime = datetime.now().strftime("%d%m%YZ%H%M%ST")
posts.posts.append({'userID': userID, 'title': title, 'content': content, 'pubdate': datetime, 'editdate': datetime}) posts.posts.append({'userID': userID, 'title': title, 'content': content, 'pubdate': datetime, 'editdate': datetime})