diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-05-25 14:52:42 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-05-25 14:58:34 +0200 |
commit | 86ceea054f5f85157b04473bac5bfb6ff86ca31f (patch) | |
tree | e8216f2f36952818427e633b641a54a6ff26379a /index.php | |
parent | 61c15aa5554431893ea5ebe800a9a625dca5aff9 (diff) | |
download | Shaarli-86ceea054f5f85157b04473bac5bfb6ff86ca31f.tar.gz Shaarli-86ceea054f5f85157b04473bac5bfb6ff86ca31f.tar.zst Shaarli-86ceea054f5f85157b04473bac5bfb6ff86ca31f.zip |
Add a whitelist of protocols for URLs
- for Shaare
- for markdown description links and images
Not whitelisted protocols will be replaced by `http://`
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 8 |
1 files changed, 1 insertions, 7 deletions
@@ -1237,13 +1237,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
1237 | // Remove duplicates. | 1237 | // Remove duplicates. |
1238 | $tags = implode(' ', array_unique(explode(' ', $tags))); | 1238 | $tags = implode(' ', array_unique(explode(' ', $tags))); |
1239 | 1239 | ||
1240 | $url = trim($_POST['lf_url']); | 1240 | $url = whitelist_protocols(trim($_POST['lf_url']), $conf->get('security.allowed_protocols')); |
1241 | if (! startsWith($url, 'http:') && ! startsWith($url, 'https:') | ||
1242 | && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:') | ||
1243 | && ! startsWith($url, '?') && ! startsWith($url, 'javascript:') | ||
1244 | ) { | ||
1245 | $url = 'http://' . $url; | ||
1246 | } | ||
1247 | 1241 | ||
1248 | $link = array( | 1242 | $link = array( |
1249 | 'id' => $id, | 1243 | 'id' => $id, |