From 016b40f99d679f0787f7c8a5f61f4a411b6c3632 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 23 Apr 2017 12:46:48 +0200 Subject: Render comments when storing them in the database Instead of converting package comments from plain text to HTML code when they are displayed, do the conversion when the comment is posted and store the rendered result in the database. The conversion itself is done by a Python script which uses Bleach for sanitizing the text. Signed-off-by: Lukas Fleischer --- test/setup.sh | 1 + test/t2600-rendercomment.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 test/t2600-rendercomment.sh (limited to 'test') diff --git a/test/setup.sh b/test/setup.sh index b71e73e8..f29695a6 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -16,6 +16,7 @@ TUVOTEREMINDER="$TOPLEVEL/aurweb/scripts/tuvotereminder.py" PKGMAINT="$TOPLEVEL/aurweb/scripts/pkgmaint.py" AURBLUP="$TOPLEVEL/aurweb/scripts/aurblup.py" NOTIFY="$TOPLEVEL/aurweb/scripts/notify.py" +RENDERCOMMENT="$TOPLEVEL/aurweb/scripts/rendercomment.py" # Create the configuration file and a dummy notification script. cat >config <<-EOF diff --git a/test/t2600-rendercomment.sh b/test/t2600-rendercomment.sh new file mode 100755 index 00000000..8d79336d --- /dev/null +++ b/test/t2600-rendercomment.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +test_description='rendercomment tests' + +. ./setup.sh + +test_expect_success 'Test comment rendering.' ' + cat <<-EOD | sqlite3 aur.db && + INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (1, 1, "Hello world! + This is a comment.", ""); + EOD + "$RENDERCOMMENT" 1 && + cat <<-EOD >expected && + Hello world!
This is a comment. + EOD + cat <<-EOD | sqlite3 aur.db >actual && + SELECT RenderedComment FROM PackageComments WHERE ID = 1; + EOD + test_cmp actual expected +' + +test_done -- cgit v1.2.3-24-g4f1b