diff --git a/lib/private/app.php b/lib/private/app.php index 1a32fcfcf77b4d84cca17af2fbd3b7ea4760144e..d5e07ffdbccde4ae96b87422caed2343266f2efb 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -1223,23 +1223,27 @@ class OC_App { // just modify the description if it is available // otherwise this will create a $data element with an empty 'description' if (isset($data['description'])) { - // sometimes the description contains line breaks and they are then also - // shown in this way in the app management which isn't wanted as HTML - // manages line breaks itself - - // first of all we split on empty lines - $paragraphs = preg_split("!\n[[:space:]]*\n!mu", $data['description']); - - $result = []; - foreach ($paragraphs as $value) { - // replace multiple whitespace (tabs, space, newlines) inside a paragraph - // with a single space - also trims whitespace - $result[] = trim(preg_replace('![[:space:]]+!mu', ' ', $value)); - } + if (is_string($data['description'])) { + // sometimes the description contains line breaks and they are then also + // shown in this way in the app management which isn't wanted as HTML + // manages line breaks itself + + // first of all we split on empty lines + $paragraphs = preg_split("!\n[[:space:]]*\n!mu", $data['description']); + + $result = []; + foreach ($paragraphs as $value) { + // replace multiple whitespace (tabs, space, newlines) inside a paragraph + // with a single space - also trims whitespace + $result[] = trim(preg_replace('![[:space:]]+!mu', ' ', $value)); + } - // join the single paragraphs with a empty line in between - $data['description'] = implode("\n\n", $result); + // join the single paragraphs with a empty line in between + $data['description'] = implode("\n\n", $result); + } else { + $data['description'] = ''; + } } return $data; diff --git a/tests/lib/app.php b/tests/lib/app.php index 9724c6e23449758ae02ff5fc74459a789ab35ffa..485091cee4ce9861003404266aeaa3a5645faaed 100644 --- a/tests/lib/app.php +++ b/tests/lib/app.php @@ -510,6 +510,10 @@ class Test_App extends \Test\TestCase { ['not-a-description' => " \t This is a multiline \n test with \n \t some new lines "], ['not-a-description' => " \t This is a multiline \n test with \n \t some new lines "] ], + [ + ['description' => [100, 'bla']], + ['description' => ""] + ], ]; }