aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-10-01 21:51:53 -0400
committercash <cash.costello@gmail.com>2011-10-01 21:51:53 -0400
commit3f3994647b238f05233da5f22f75a88582562308 (patch)
treea867edc42c19f417a57da709b08d8ec96c1e1556 /mod
parent00433c37e49e1ca706809a1a5f1c515cd784fc22 (diff)
downloadelgg-3f3994647b238f05233da5f22f75a88582562308.tar.gz
elgg-3f3994647b238f05233da5f22f75a88582562308.tar.bz2
Fixes #3686 added work around for PHP bug when validating URLs with dashes
Diffstat (limited to 'mod')
-rw-r--r--mod/bookmarks/actions/bookmarks/save.php19
-rw-r--r--mod/bookmarks/languages/en.php3
2 files changed, 20 insertions, 2 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);
}
diff --git a/mod/bookmarks/languages/en.php b/mod/bookmarks/languages/en.php
index 1d32a0344..0478e292f 100644
--- a/mod/bookmarks/languages/en.php
+++ b/mod/bookmarks/languages/en.php
@@ -24,7 +24,7 @@ $english = array(
'bookmarks:with' => "Share with",
'bookmarks:new' => "A new bookmark",
'bookmarks:via' => "via bookmarks",
- 'bookmarks:address' => "Address of the resource to bookmark",
+ 'bookmarks:address' => "Address of the bookmark",
'bookmarks:none' => 'No bookmarks',
'bookmarks:delete:confirm' => "Are you sure you want to delete this resource?",
@@ -75,6 +75,7 @@ $english = array(
*/
'bookmarks:save:failed' => "Your bookmark could not be saved. Make sure you've entered a title and address and then try again.",
+ 'bookmarks:save:invalid' => "The address of the bookmark is invalid and could nto be saved.",
'bookmarks:delete:failed' => "Your bookmark could not be deleted. Please try again.",
);