summaryrefslogtreecommitdiff
path: root/lib/html.source.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/html.source.sh')
-rw-r--r--lib/html.source.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/html.source.sh b/lib/html.source.sh
index 7056f24..b60ac75 100644
--- a/lib/html.source.sh
+++ b/lib/html.source.sh
@@ -4,6 +4,7 @@ html::encode () {
s|\&|\&|g;
s|<|\&lt;|g;
s|>|\&gt;|g;
+ s|'\''|\&#39;|g;
' <<< "$@"
}
@@ -70,7 +71,7 @@ html::make_link () {
descr="$link"
fi
- echo "<a class='textlink' href='$link'>$descr</a><br />"
+ echo "<a class='textlink' href='$(html::encode "$link")'>$descr</a><br />"
}
html::process_inline () {
@@ -214,6 +215,10 @@ html::test::default () {
assert::equals "$(generate::make_link html "$line")" \
"<a class='textlink' href='https://example.org'>https://example.org</a><br />"
+ line="=> https://example.org/foo'bar"
+ assert::equals "$(generate::make_link html "$line")" \
+ "<a class='textlink' href='https://example.org/foo&#39;bar'>https://example.org/foo'bar</a><br />"
+
line='=> index.html'
assert::equals "$(generate::make_link html "$line")" \
"<a class='textlink' href='index.html'>index.html</a><br />"