aboutsummaryrefslogtreecommitdiff
path: root/mod/bookmarks/actions
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bookmarks/actions')
-rw-r--r--mod/bookmarks/actions/bookmarks/save.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/mod/bookmarks/actions/bookmarks/save.php b/mod/bookmarks/actions/bookmarks/save.php
index 19bb3c73a..f240c4b26 100644
--- a/mod/bookmarks/actions/bookmarks/save.php
+++ b/mod/bookmarks/actions/bookmarks/save.php
@@ -24,7 +24,24 @@ if ($address && !preg_match("#^((ht|f)tps?:)?//#i", $address)) {
$address = "http://$address";
}
-if (!$title || !$address || !filter_var($address, FILTER_VALIDATE_URL)) {
+if (!$title || !$address) {
+ register_error(elgg_echo('bookmarks:save:failed'));
+ forward(REFERER);
+}
+
+// see https://bugs.php.net/bug.php?id=51192
+$php_5_2_13_and_below = version_compare(PHP_VERSION, '5.2.14', '<');
+$php_5_3_0_to_5_3_2 = version_compare(PHP_VERSION, '5.3.0', '>=') &&
+ version_compare(PHP_VERSION, '5.3.3', '<');
+
+$validated = false;
+if ($php_5_2_13_and_below || $php_5_3_0_to_5_3_2) {
+ $tmp_address = str_replace("-", "", $address);
+ $validated = filter_var($tmp_address, FILTER_VALIDATE_URL);
+} else {
+ $validated = filter_var($address, FILTER_VALIDATE_URL);
+}
+if (!$validated) {
register_error(elgg_echo('bookmarks:save:failed'));
forward(REFERER);
}