summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-07-08 10:32:53 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-07-08 10:32:53 +0200
commit96b97d1567492903df104271d292c6d5dd12d1bf (patch)
tree86921e7de7da2bcea1cb1bb6f1e91f6a9420232d
parent97e49e422f3024ce052f767cdbe917315f7eee6c (diff)
parent2727d9797dae3a7a4b9557225250e3f195e96582 (diff)
downloadnextcloud-server-96b97d1567492903df104271d292c6d5dd12d1bf.tar.gz
nextcloud-server-96b97d1567492903df104271d292c6d5dd12d1bf.zip
Merge pull request #17338 from owncloud/stable8.1-backport-17252
[stable8.1] Only do the description kung-fu on strings - fixes #17028
-rw-r--r--lib/private/app.php34
-rw-r--r--tests/lib/app.php4
2 files changed, 23 insertions, 15 deletions
diff --git a/lib/private/app.php b/lib/private/app.php
index 22f5343373a..e45d9ac07ba 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -1225,23 +1225,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 9724c6e2344..485091cee4c 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' => ""]
+ ],
];
}