diff --git a/apps/updatenotification/lib/UpdateChecker.php b/apps/updatenotification/lib/UpdateChecker.php index f7b45a03f2..ec8e119049 100644 --- a/apps/updatenotification/lib/UpdateChecker.php +++ b/apps/updatenotification/lib/UpdateChecker.php @@ -59,7 +59,7 @@ class UpdateChecker { if (strpos($data['changelog'], 'https://') === 0) { $result['changelog'] = $data['changelog']; } - if($data['whatsNew'] !== null) { + if (is_array($data['whatsNew']) && count($data['whatsNew']) <= 3) { $result['whatsNew'] = $data['whatsNew']; } diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php index d5915a9c10..3e06990750 100644 --- a/apps/updatenotification/tests/Settings/AdminTest.php +++ b/apps/updatenotification/tests/Settings/AdminTest.php @@ -99,6 +99,8 @@ class AdminTest extends TestCase { 'updateAvailable' => true, 'updateVersion' => '8.1.2', 'downloadLink' => 'https://downloads.nextcloud.org/server', + 'changelog' => 'https://nextcloud.com/changelog/#8.1.2', + 'whatsNew' => ['Autoshare to mother-in-law', 'Faster backend', 'Sparkling frontend'], 'updaterEnabled' => true, 'versionIsEol' => false, ]); @@ -124,6 +126,8 @@ class AdminTest extends TestCase { 'channels' => $channels, 'newVersionString' => '8.1.2', 'downloadLink' => 'https://downloads.nextcloud.org/server', + 'changelogURL' => 'https://nextcloud.com/changelog/#8.1.2', + 'whatsNew' => ['Autoshare to mother-in-law', 'Faster backend', 'Sparkling frontend'], 'updaterEnabled' => true, 'versionIsEol' => false, 'isDefaultUpdateServerURL' => true, diff --git a/apps/updatenotification/tests/UpdateCheckerTest.php b/apps/updatenotification/tests/UpdateCheckerTest.php index 6f5edf0c78..0a82f950b9 100644 --- a/apps/updatenotification/tests/UpdateCheckerTest.php +++ b/apps/updatenotification/tests/UpdateCheckerTest.php @@ -51,6 +51,8 @@ class UpdateCheckerTest extends TestCase { 'versionstring' => 'Nextcloud 123', 'web'=> 'javascript:alert(1)', 'url'=> 'javascript:alert(2)', + 'changelog' => 'javascript:alert(3)', + 'whatsNew' => 'javascript:alert(4)', 'autoupdater'=> '0', 'eol'=> '1', ]); @@ -73,6 +75,8 @@ class UpdateCheckerTest extends TestCase { 'versionstring' => 'Nextcloud 123', 'web'=> 'https://docs.nextcloud.com/myUrl', 'url'=> 'https://downloads.nextcloud.org/server', + 'changelog' => 'https://nextcloud.com/changelog/#123.0.0', + 'whatsNew' => ['Brews coffee', 'Makes appointments', 'Orchestrates Terminators'], 'autoupdater'=> '1', 'eol'=> '0', ]); @@ -84,6 +88,8 @@ class UpdateCheckerTest extends TestCase { 'versionIsEol' => false, 'updateLink' => 'https://docs.nextcloud.com/myUrl', 'downloadLink' => 'https://downloads.nextcloud.org/server', + 'changelog' => 'https://nextcloud.com/changelog/#123.0.0', + 'whatsNew' => ['Brews coffee', 'Makes appointments', 'Orchestrates Terminators'], ]; $this->assertSame($expected, $this->updateChecker->getUpdateState()); } diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php index 30774393ec..bc50521163 100644 --- a/lib/private/Updater/VersionCheck.php +++ b/lib/private/Updater/VersionCheck.php @@ -97,7 +97,7 @@ class VersionCheck { $tmp['versionstring'] = (string)$data->versionstring; $tmp['url'] = (string)$data->url; $tmp['web'] = (string)$data->web; - $tmp['changelog'] = isset($data->changelog) ? (string)$data->changelog : null; + $tmp['changelog'] = isset($data->changelog) ? (string)$data->changelog : ''; // TODO: one's it is decided, use the proper field… $tmp['whatsNew'] = isset($data->whatsNew) ? ((array)$data->whatsNew)['item'] : null; $tmp['whatsNew'] = isset($data->whatsNew_admin) ? ((array)$data->whatsNew_admin)['item'] : (string)$data->whatsNew; diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php index 216510b662..c7165b34ef 100644 --- a/tests/lib/Updater/VersionCheckTest.php +++ b/tests/lib/Updater/VersionCheckTest.php @@ -84,6 +84,8 @@ class VersionCheckTest extends \Test\TestCase { 'versionstring' => 'ownCloud 8.0.4', 'url' => 'https://download.example.org/community/owncloud-8.0.4.zip', 'web' => 'http://doc.example.org/server/8.0/admin_manual/maintenance/upgrade.html', + 'changelog' => '', + 'whatsNew' => '', 'autoupdater' => '0', 'eol' => '1', ]; @@ -181,6 +183,8 @@ class VersionCheckTest extends \Test\TestCase { 'versionstring' => '', 'url' => '', 'web' => '', + 'changelog' => '', + 'whatsNew' => '', 'autoupdater' => '', 'eol' => '0', ]; @@ -275,6 +279,8 @@ class VersionCheckTest extends \Test\TestCase { 'versionstring' => '', 'url' => '', 'web' => '', + 'changelog' => '', + 'whatsNew' => '', 'autoupdater' => '', 'eol' => '0', ];