Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL checking improved #4670

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions components/com_wrapper/views/wrapper/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,25 @@ public function display($tpl = null)

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