diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3c43fb..288c2c8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog
+## 2.3.3
+- Remove usage of deprecated methods
+
## 2.3.2
- Compatible with Nextcloud 21
diff --git a/appinfo/app.php b/appinfo/app.php
deleted file mode 100644
index 6c92aa5..0000000
--- a/appinfo/app.php
+++ /dev/null
@@ -1,7 +0,0 @@
-query(Application::class);
-$app->register();
-
diff --git a/appinfo/info.xml b/appinfo/info.xml
index fa56aa5..2f7ef77 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -7,7 +7,7 @@
- 2.3.2
+ 2.3.3
agpl
Robin Appelman
@@ -44,6 +44,6 @@ A full list of features can be found [in the README](https://github.com/icewind1
-
+
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 377ac4b..ad5b0a3 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -29,44 +29,30 @@
use OC\Security\CSP\ContentSecurityPolicy;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
+use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
+use OCA\FilesMarkdown\Listener\CSPListener;
+use OCA\FilesMarkdown\Listener\ScriptListener;
use OCP\AppFramework\App;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Security\CSP\AddContentSecurityPolicyEvent;
use OCP\Util;
-class Application extends App {
+class Application extends App implements IBootstrap {
public const APP_ID = 'files_markdown';
public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);
}
- public function register() {
- $server = $this->getContainer()->getServer();
-
- /** @var IEventDispatcher $dispatcher */
- $dispatcher = $server->query(IEventDispatcher::class);
-
- $dispatcher->addListener(LoadAdditionalScriptsEvent::class, function () use ($server) {
- $policy = new ContentSecurityPolicy();
- $policy->setAllowedImageDomains(['*']);
- $frameDomains = $policy->getAllowedFrameDomains();
- $frameDomains[] = 'www.youtube.com';
- $frameDomains[] = 'prezi.com';
- $frameDomains[] = 'player.vimeo.com';
- $frameDomains[] = 'vine.co';
- $policy->setAllowedFrameDomains($frameDomains);
- $server->getContentSecurityPolicyManager()->addDefaultPolicy($policy);
-
- //load the required files
- Util::addscript('files_markdown', '../build/editor');
- Util::addStyle('files_markdown', '../build/styles');
- Util::addStyle('files_markdown', 'preview');
- });
+ public function register(IRegistrationContext $context): void {
+ $context->registerEventListener(LoadAdditionalScriptsEvent::class, ScriptListener::class);
+ $context->registerEventListener(AddContentSecurityPolicyEvent::class, CSPListener::class);
+ $context->registerEventListener(BeforeTemplateRenderedEvent::class, CSPListener::class);
+ }
- $dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', function () {
- Util::addScript('files_markdown', '../build/editor');
- Util::addStyle('files_markdown', '../build/styles');
- Util::addStyle('files_markdown', 'preview');
- });
+ public function boot(IBootContext $context): void {
}
}
diff --git a/lib/Listener/CSPListener.php b/lib/Listener/CSPListener.php
new file mode 100644
index 0000000..92fbe1b
--- /dev/null
+++ b/lib/Listener/CSPListener.php
@@ -0,0 +1,47 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\FilesMarkdown\Listener;
+
+
+use OCP\AppFramework\Http\ContentSecurityPolicy;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use OCP\Security\CSP\AddContentSecurityPolicyEvent;
+
+class CSPListener implements IEventListener {
+ public function handle(Event $event): void {
+ if (!($event instanceof AddContentSecurityPolicyEvent)) {
+ return;
+ }
+
+ $policy = new ContentSecurityPolicy();
+ $policy->addAllowedImageDomain('*');
+ $policy->addAllowedFrameDomain('prezi.com');
+ $policy->addAllowedFrameDomain('player.vimeo.com');
+ $policy->addAllowedFrameDomain('vine.co');
+ $policy->addAllowedFrameDomain('www.youtube.com');
+
+ $event->addPolicy($policy);
+ }
+}
diff --git a/lib/Listener/ScriptListener.php b/lib/Listener/ScriptListener.php
new file mode 100644
index 0000000..ed40d29
--- /dev/null
+++ b/lib/Listener/ScriptListener.php
@@ -0,0 +1,36 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\FilesMarkdown\Listener;
+
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use OCP\Util;
+
+class ScriptListener implements IEventListener {
+ public function handle(Event $event): void {
+ Util::addscript('files_markdown', '../build/editor');
+ Util::addStyle('files_markdown', '../build/styles');
+ Util::addStyle('files_markdown', 'preview');
+ }
+}