[CORE] Fix undefined offset warnings in different files
This problem was presentend in the following issue: https://notabug.org/diogo/gnu-social/issues/60 AcceptHeader/util: - Perform isset before using the required array values
This commit is contained in:
parent
fe2168c5ae
commit
8f070f53ec
@ -49,12 +49,18 @@ class AcceptHeader extends \ArrayObject
|
|||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$elems = explode(';', $item);
|
$elems = explode(';', $item);
|
||||||
|
|
||||||
$acceptElement = [];
|
$mime = current($elems);
|
||||||
$mime = current($elems);
|
$types = explode('/', $mime);
|
||||||
list($type, $subtype) = explode('/', $mime);
|
|
||||||
$acceptElement['type'] = trim($type);
|
if (!isset($types[1])) {
|
||||||
$acceptElement['subtype'] = trim($subtype);
|
continue;
|
||||||
$acceptElement['raw'] = $mime;
|
}
|
||||||
|
|
||||||
|
$acceptElement = [
|
||||||
|
'raw' => $mime,
|
||||||
|
'type' => trim($types[0]),
|
||||||
|
'subtype' => trim($types[1]),
|
||||||
|
];
|
||||||
|
|
||||||
$acceptElement['params'] = [];
|
$acceptElement['params'] = [];
|
||||||
while (next($elems)) {
|
while (next($elems)) {
|
||||||
|
@ -2100,7 +2100,7 @@ function common_negotiate_type($cprefs, $sprefs)
|
|||||||
|
|
||||||
foreach (array_keys($sprefs) as $type) {
|
foreach (array_keys($sprefs) as $type) {
|
||||||
$parts = explode('/', $type);
|
$parts = explode('/', $type);
|
||||||
if ($parts[1] != '*') {
|
if (isset($parts[1]) && $parts[1] != '*') {
|
||||||
$ckey = common_mime_type_match($type, $cprefs);
|
$ckey = common_mime_type_match($type, $cprefs);
|
||||||
if ($ckey) {
|
if ($ckey) {
|
||||||
$combine[$type] = $sprefs[$type] * $cprefs[$ckey];
|
$combine[$type] = $sprefs[$type] * $cprefs[$ckey];
|
||||||
@ -2110,7 +2110,7 @@ function common_negotiate_type($cprefs, $sprefs)
|
|||||||
|
|
||||||
foreach (array_keys($cprefs) as $type) {
|
foreach (array_keys($cprefs) as $type) {
|
||||||
$parts = explode('/', $type);
|
$parts = explode('/', $type);
|
||||||
if ($parts[1] != '*' && !array_key_exists($type, $sprefs)) {
|
if (isset($parts[1]) && $parts[1] != '*' && !array_key_exists($type, $sprefs)) {
|
||||||
$skey = common_mime_type_match($type, $sprefs);
|
$skey = common_mime_type_match($type, $sprefs);
|
||||||
if ($skey) {
|
if ($skey) {
|
||||||
$combine[$type] = $sprefs[$skey] * $cprefs[$type];
|
$combine[$type] = $sprefs[$skey] * $cprefs[$type];
|
||||||
|
Loading…
Reference in New Issue
Block a user