aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/output.php13
-rw-r--r--views/default/output/confirmlink.php2
-rw-r--r--views/default/output/url.php4
3 files changed, 13 insertions, 6 deletions
diff --git a/engine/lib/output.php b/engine/lib/output.php
index 335a53ac4..35ace7c09 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -155,11 +155,20 @@ function elgg_format_url($url) {
* @return string The absolute url
*/
function elgg_normalize_url($url) {
+ // 'http://example.com', 'https://example.com', '//example.com'
if (preg_match("#^(https?:)?//#i", $url)) {
return $url;
- }
+ }
+
+ // 'example.com', 'example.com/subpage'
+ elseif (preg_match("#[^/]*\.[^/]*/?#i", $url)) {
+ return "http://$url";
+ }
- return elgg_get_site_url().$url;
+ // 'pg/page/handler'
+ else {
+ return elgg_get_site_url().$url;
+ }
}
/**
diff --git a/views/default/output/confirmlink.php b/views/default/output/confirmlink.php
index d7bb5c56f..4d1bc0ab9 100644
--- a/views/default/output/confirmlink.php
+++ b/views/default/output/confirmlink.php
@@ -18,7 +18,7 @@ if (!$confirm) {
}
// always generate missing action tokens
-$link = elgg_add_action_tokens_to_url($vars['href']);
+$link = elgg_add_action_tokens_to_url(elgg_normalize_url($vars['href']));
if (isset($vars['class']) && $vars['class']) {
$class = 'class="' . $vars['class'] . '"';
diff --git a/views/default/output/url.php b/views/default/output/url.php
index 9dd0bf3f5..2a01e32d0 100644
--- a/views/default/output/url.php
+++ b/views/default/output/url.php
@@ -51,9 +51,7 @@ if (!empty($url)) {
$text = htmlentities($url, ENT_QUOTES, 'UTF-8');
}
- if ((substr_count($url, "http://") == 0) && (substr_count($url, "https://") == 0)) {
- $url = "http://" . $url;
- }
+ $url = elgg_normalize_url($url);
if (isset($vars['is_action'])) {
$url = elgg_add_action_tokens_to_url($url);