mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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 <lfleischer@archlinux.org>
This commit is contained in:
parent
4abde895a5
commit
016b40f99d
9 changed files with 107 additions and 4 deletions
|
@ -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
|
||||
|
|
22
test/t2600-rendercomment.sh
Executable file
22
test/t2600-rendercomment.sh
Executable file
|
@ -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!<br>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
|
Loading…
Add table
Add a link
Reference in a new issue