[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:
tenma
2019-09-01 21:33:11 +01:00
committed by Diogo Cordeiro
parent 19409cb999
commit 2e66cbeb60
2 changed files with 14 additions and 8 deletions

View File

@@ -49,12 +49,18 @@ class AcceptHeader extends \ArrayObject
foreach ($items as $item) {
$elems = explode(';', $item);
$acceptElement = [];
$mime = current($elems);
list($type, $subtype) = explode('/', $mime);
$acceptElement['type'] = trim($type);
$acceptElement['subtype'] = trim($subtype);
$acceptElement['raw'] = $mime;
$mime = current($elems);
$types = explode('/', $mime);
if (!isset($types[1])) {
continue;
}
$acceptElement = [
'raw' => $mime,
'type' => trim($types[0]),
'subtype' => trim($types[1]),
];
$acceptElement['params'] = [];
while (next($elems)) {