Skip to content

Commit

Permalink
URL checking improved
Browse files Browse the repository at this point in the history
When adding the scheme to an URL use correct scheme (http or https) and port.
Checking for "http" or "https" via strstr() in the URL matched also these strings embedded in the URL (e.g. in /static/http/index.html), due to that checks changed to strpos().
  • Loading branch information
jo-sf committed Oct 14, 2014
1 parent 3bf33c7 commit 8f3d2d3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions components/com_wrapper/views/wrapper/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,20 @@ public function display($tpl = null)

if ($params->def('add_scheme', 1))
{
// Adds 'http://' if none is set
// Adds 'http://' or 'https://' if none is set
if (substr($url, 0, 1) == '/')
{
// Relative url in component. Use server http_host.
$wrapper->url = 'http://' . $_SERVER['HTTP_HOST'] . $url;
// Relative url in component. Use scheme + host + port.
$wrapper->url = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $url;
}
elseif (!strstr($url, 'http') && !strstr($url, 'https'))
elseif (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0)
{
// Url doesn't start with either 'http://' or 'https://'. Add 'http://'.
$wrapper->url = 'http://' . $url;
}
else
{
// Url starts with either 'http://' or 'https://'. Do not change it.
$wrapper->url = $url;
}
}
Expand Down

0 comments on commit 8f3d2d3

Please sign in to comment.