summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFrédéric Mangano-Tarumi <fmang@mg0.fr>2020-02-01 19:07:41 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2020-02-02 12:12:43 +0100
commit199f34e42e78ca97f154a4880b77b3f1d01fa9da (patch)
tree41f90558369ee8a7491bec31c456a0ee2562aa32 /test
parent0fc69e96bdd1197ca2b91bcd16a3064366954c06 (diff)
downloadaur-199f34e42e78ca97f154a4880b77b3f1d01fa9da.tar.gz
aur-199f34e42e78ca97f154a4880b77b3f1d01fa9da.tar.xz
rendercomment: safer auto-linkification of URLs
Fixes a few edge cases: - URLs within code blocks used to get redundant <> added, breaking bash code snippets like `curl https://...` into `curl <https://...>`. - Links written with markdown's <https://...> syntax also used to get an extra pair of brackets. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'test')
-rwxr-xr-xtest/t2600-rendercomment.sh15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/t2600-rendercomment.sh b/test/t2600-rendercomment.sh
index 7b3a4a8d..b0209eb5 100755
--- a/test/t2600-rendercomment.sh
+++ b/test/t2600-rendercomment.sh
@@ -51,11 +51,22 @@ test_expect_success 'Test HTML sanitizing.' '
test_expect_success 'Test link conversion.' '
cat <<-EOD | sqlite3 aur.db &&
- INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (4, 1, "Visit https://www.archlinux.org/.", "");
+ INSERT INTO PackageComments (ID, PackageBaseID, Comments, RenderedComment) VALUES (4, 1, "
+ Visit https://www.archlinux.org/.
+ Visit <https://www.archlinux.org/>.
+ Visit \`https://www.archlinux.org/\`.
+ Visit [Arch Linux](https://www.archlinux.org/).
+ Visit [Arch Linux][arch].
+ [arch]: https://www.archlinux.org/
+ ", "");
EOD
"$RENDERCOMMENT" 4 &&
cat <<-EOD >expected &&
- <p>Visit <a href="https://www.archlinux.org/">https://www.archlinux.org/</a>.</p>
+ <p>Visit <a href="https://www.archlinux.org/">https://www.archlinux.org/</a>.
+ Visit <a href="https://www.archlinux.org/">https://www.archlinux.org/</a>.
+ Visit <code>https://www.archlinux.org/</code>.
+ Visit <a href="https://www.archlinux.org/">Arch Linux</a>.
+ Visit <a href="https://www.archlinux.org/">Arch Linux</a>.</p>
EOD
cat <<-EOD | sqlite3 aur.db >actual &&
SELECT RenderedComment FROM PackageComments WHERE ID = 4;