Handle the case when the given contact url or address is empty

2022.09-rc
Michael 2017-04-18 18:50:01 +00:00
rodzic 08209419aa
commit 828ae671f0
1 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -212,6 +212,10 @@ function unmark_for_death($contact) {
function get_contact_details_by_url($url, $uid = -1, $default = array()) { function get_contact_details_by_url($url, $uid = -1, $default = array()) {
static $cache = array(); static $cache = array();
if ($url == '') {
return $default;
}
if ($uid == -1) { if ($uid == -1) {
$uid = local_user(); $uid = local_user();
} }
@ -328,6 +332,10 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
function get_contact_details_by_addr($addr, $uid = -1) { function get_contact_details_by_addr($addr, $uid = -1) {
static $cache = array(); static $cache = array();
if ($addr == '') {
return array();
}
if ($uid == -1) { if ($uid == -1) {
$uid = local_user(); $uid = local_user();
} }
@ -534,6 +542,10 @@ function get_contact($url, $uid = 0, $no_update = false) {
$data = array(); $data = array();
$contact_id = 0; $contact_id = 0;
if ($url == '') {
return 0;
}
// We first try the nurl (http://server.tld/nick), most common case // We first try the nurl (http://server.tld/nick), most common case
$contacts = q("SELECT `id`, `avatar-date` FROM `contact` $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
WHERE `nurl` = '%s' WHERE `nurl` = '%s'