aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authornodiscc <nodiscc@gmail.com>2015-06-24 01:04:50 +0200
committernodiscc <nodiscc@gmail.com>2015-06-24 01:08:30 +0200
commit64bc92e3ac8f5e66d2bc14206ede31e6679d8c13 (patch)
tree93856d99964edd4109301ada6b028ff33985e470 /application/Utils.php
parenteaefcba724e93c5f6b426ad8855ab1af8ac8212a (diff)
downloadShaarli-64bc92e3ac8f5e66d2bc14206ede31e6679d8c13.tar.gz
Shaarli-64bc92e3ac8f5e66d2bc14206ede31e6679d8c13.tar.zst
Shaarli-64bc92e3ac8f5e66d2bc14206ede31e6679d8c13.zip
move escape() and sanitizeLink() to application/Utils.php
prevents 'PHP Fatal error: Call to undefined function sanitizeLink() in Shaarli/application/LinkDB.php on line 255' in tests
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/application/Utils.php b/application/Utils.php
index 737f1502..82220bfc 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -42,4 +42,31 @@ function endsWith($haystack, $needle, $case=true)
42 } 42 }
43 return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0); 43 return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0);
44} 44}
45
46/**
47 * Same as nl2br(), but escapes < and >
48 */
49function nl2br_escaped($html)
50{
51 return str_replace('>','&gt;',str_replace('<','&lt;',nl2br($html)));
52}
53
54/**
55 * htmlspecialchars wrapper
56 */
57function escape($str)
58{
59 return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false);
60}
61
62/**
63 * Link sanitization before templating
64 */
65function sanitizeLink(&$link)
66{
67 $link['url'] = escape($link['url']); // useful?
68 $link['title'] = escape($link['title']);
69 $link['description'] = escape($link['description']);
70 $link['tags'] = escape($link['tags']);
71}
45?> 72?>