shii.moe

Source for `shii.moe' website.
git clone git://git.knutsen.co/shii.moe
Log | Files | Refs | README | LICENSE

commit b0e0e7e03cf7902b03c6e887039e2ee0dc91c15d
parent a9c4cd04c558c6542e0506f203239c4a8de6a978
Author: Demonstrandum <samuel@knutsen.co>
Date:   Sun, 30 Oct 2022 19:56:15 +0000

Reject badspeak.

Diffstat:
Mshiimoe/__init__.py | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/shiimoe/__init__.py b/shiimoe/__init__.py @@ -61,7 +61,7 @@ def get_blog_posts(): with open(f"{BLOG_PATH}/{file}", 'r') as f: content = md.convert(f.read()) meta = md.Meta - + published = meta['published'] updated = meta.get('updated', published) posts.append({ @@ -229,7 +229,8 @@ def blogpost(slug): return template('blogpost.html', **keywords) -LINK_MATCH = re.compile("https?://") +LINK_MATCH = re.compile(r"https?://") +BAD_SPEAK = re.compile(r"@crypt|crypto\b|get rich", re.IGNORECASE) @app.route('/postcomment', methods=['POST']) def postcomment(): @@ -255,8 +256,10 @@ def postcomment(): return err("No more than 850 characters!") if name.lower() == "annasysdek": return err("Sorry, that name is toxic. Pick another.") - if len(LINK_MATCH.findall(comment)) != 0: + if LINK_MATCH.search(comment) != None: return err("No links!") + if BAD_SPEAK.search(comment) != None: + return err("Try again in proper newspeak! No badspeak.") comments = read_comments() if any(c['comment'] == comment for c in comments): @@ -274,7 +277,6 @@ def postcomment(): return redirect('/guestbook', code=302) - @app.route('/<path:filepath>') def serve_static(filepath): path, filename = os.path.split(filepath)