DragonByte Tech
Well-known member
- Affected version
- 2.2.6pl2
Problem:
When using the
Test Cases:
Suggested Fix:
Apply the following below
Notes:
I used
When using the
XF\Validator\Url
class to validate URLs, entering a non-www URL does not correctly apply the schema.Test Cases:
https://google.com
works.www.google.com
works.google.com
does not, and asks to input a valid URL.Suggested Fix:
Apply the following below
else if (substr(strtolower($value), 0, 4) == 'www.')
PHP:
else
{
$scheme = parse_url($value, PHP_URL_SCHEME);
if ($scheme === null)
{
/** @noinspection HttpUrlsUsage */
$value = 'http://' . $value;
}
}
Notes:
I used
===
because of the following note in the php.net documentation for parse_url
: "On seriously malformed URLs, parse_url() may return false."