Continued with #3010:

- removed added debug messages (maybe they will come back in accordance to
  code-style guidelines?)
- converted $a->get_baseurl() back to App::get_baseurl()
- reverted back other code I have touched/merged as this was double:
  (substr($url, 0, 4) !== 'http') on $url = 'https://bla'; will be FALSE
  (means found http at start), too.

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-14 16:59:35 +01:00
parent 4b860e7575
commit 23d4db5149
5 changed files with 16 additions and 27 deletions

View file

@ -388,32 +388,23 @@ function http_status_exit($val, $description = array()) {
* @return boolean True if it's a valid URL, fals if something wrong with it
*/
function validate_url(&$url) {
logger(sprintf('[%s:%d]: url=%s - CALLED!', __FUNCTION__, __LINE__, $url), LOGGER_TRACE);
if(get_config('system','disable_url_validation'))
logger(sprintf('[%s:%d]: URL validation disabled, returning TRUE - EXIT!', __FUNCTION__, __LINE__), LOGGER_TRACE);
return true;
// no naked subdomains (allow localhost for tests)
if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
logger(sprintf('[%s:%d]: URL is not complete, returning FALSE - EXIT!', __FUNCTION__, __LINE__), LOGGER_TRACE);
return false;
if(substr($url,0,4) != 'http' && substr($url,0,5) != 'https')
if(substr($url,0,4) != 'http')
$url = 'http://' . $url;
logger(sprintf('[%s:%d]: url=%s - before parse_url() ...', __FUNCTION__, __LINE__, $url), LOGGER_DEBUG);
// @TODO Really supress function outcomes? Why not find them + debug them?
$h = @parse_url($url);
logger(sprintf('[%s:%d]: h[]=%s', __FUNCTION__, __LINE__, gettype($h)), LOGGER_DEBUG);
if((is_array($h)) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
logger(sprintf('[%s:%d]: URL %s validated. - EXIT!', __FUNCTION__, __LINE__, $url), LOGGER_TRACE);
return true;
}
logger(sprintf('[%s:%d]: URL %s maybe not valid - EXIT!', __FUNCTION__, __LINE__, $url), LOGGER_TRACE);
return false;
}