From 2c4e3db4f3696369c65740b62a9889031dd75905 Mon Sep 17 00:00:00 2001 From: akhil Date: Thu, 22 Jul 2021 18:23:10 +0530 Subject: [PATCH 1/5] Added patches for IconsCacher and SvgController --- Dockerfile | 2 ++ patches/008-icons-cacher-theme-svgs.patch | 40 +++++++++++++++++++++ patches/008-svg-controller-theme-svgs.patch | 38 ++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 patches/008-icons-cacher-theme-svgs.patch create mode 100644 patches/008-svg-controller-theme-svgs.patch diff --git a/Dockerfile b/Dockerfile index 32cbfdd4..e5a33eb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,6 +83,8 @@ RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-co RUN cd ${BASE_DIR}/custom_apps && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-custom-app.patch RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/006-recovery-email-changes.patch RUN patch -u ${BASE_DIR}/apps/settings/lib/Settings/Personal/ServerDevNotice.php -i ${TMP_PATCH_DIR}/007-remove-dev-notice.patch +RUN patch -u ${BASE_DIR}/lib/private/Template/IconsCacher.php -i ${TMP_PATCH_DIR}/008-icons-cacher-theme-svgs.patch +RUN patch -u ${BASE_DIR}/core/Controller/SvgController.php -i ${TMP_PATCH_DIR}/008-svg-controller-theme-svgs.patch RUN rm -rf ${TMP_PATCH_DIR} # autocomplete leak tweak apps frontend with sed, disable group suggestion diff --git a/patches/008-icons-cacher-theme-svgs.patch b/patches/008-icons-cacher-theme-svgs.patch new file mode 100644 index 00000000..e1f0b232 --- /dev/null +++ b/patches/008-icons-cacher-theme-svgs.patch @@ -0,0 +1,40 @@ +From: Akhil +Date: Tue, 22 Jul 2021 18:15:00 +0530 +Subject: [PATCH] Caches SVGs added via theme + +This patch modifies Icons Cacher to check theme for icons and if they exist, +cache them instead of the icons in core or apps directories + +diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCacher-new.php +--- ./lib/private/Template/IconsCacher.php 2021-07-22 18:05:40.133856200 +0530 ++++ ./lib/private/Template/IconsCacher-new.php 2021-07-22 18:08:31.650437441 +0530 +@@ -161,17 +161,26 @@ + $location = ''; + $color = ''; + $base = $this->getRoutePrefix() . '/svg/'; +- $cleanUrl = \substr($url, \strlen($base)); ++ $cleanUrl = \substr($url, \strlen($base)); ++ $theme = \OC::$server->getConfig()->getSystemValue("theme"); + if (\strpos($url, $base . 'core') === 0) { + $cleanUrl = \substr($cleanUrl, \strlen('core')); + if (\preg_match('/\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) { +- list(,$cleanUrl,$color) = $matches; ++ list(,$cleanUrl,$color) = $matches; ++ $location = \OC::$SERVERROOT . '/themes/'. $theme . '/core/img/' . $cleanUrl . '.svg'; ++ if(!file_exists($location)){ ++ $location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg'; ++ } + $location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg'; + } + } elseif (\strpos($url, $base) === 0) { + if (\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) { + list(,$app,$cleanUrl, $color) = $matches; +- $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; ++ $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; ++ $location = \OC::$SERVERROOT . '/themes/' . $theme . '/apps/' . $app . '/img/' . $cleanUrl . '.svg'; ++ if(!file_exists($location)) { ++ $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; ++ } + if ($app === 'settings') { + $location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg'; + } diff --git a/patches/008-svg-controller-theme-svgs.patch b/patches/008-svg-controller-theme-svgs.patch new file mode 100644 index 00000000..4e86543e --- /dev/null +++ b/patches/008-svg-controller-theme-svgs.patch @@ -0,0 +1,38 @@ +From: Akhil +Date: Tue, 22 Jul 2021 18:15:00 +0530 +Subject: [PATCH] Serves SVGs added via theme through SVG Controller + +This patch modifies SVG Controllers to check theme for icons and if they exist, return them before checking +app or core directories in their respective methods + +diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCacher-new.php +--- ./core/Controller/SvgController.php 2021-07-22 18:00:30.575284496 +0530 ++++ ./core/Controller/SvgController-new.php 2021-07-22 18:07:55.927091362 +0530 +@@ -81,7 +81,13 @@ + * @return DataDisplayResponse|NotFoundResponse + */ + public function getSvgFromCore(string $folder, string $fileName, string $color = 'ffffff') { +- $path = $this->serverRoot . "/core/img/$folder/$fileName.svg"; ++ $theme = \OC::$server->getConfig()->getSystemValue("theme"); ++ $path = $this->serverRoot . '/themes/' . $theme .'/core/img/' . $folder . '/' . $fileName . '.svg'; ++ if(file_exists($path)) { ++ return $this->getSvg($path, $color, $fileName); ++ } ++ ++ $path = $this->serverRoot . "/core/img/$folder/$fileName.svg"; + return $this->getSvg($path, $color, $fileName); + } + +@@ -103,7 +109,11 @@ + } catch (AppPathNotFoundException $e) { + return new NotFoundResponse(); + } +- ++ $theme = \OC::$server->getConfig()->getSystemValue("theme"); ++ $path = $this->serverRoot . '/themes/' . $theme .'/apps/' . $app . '/img/'. $fileName . '.svg'; ++ if(file_exists($path)) { ++ return $this->getSvg($path, $color, $fileName); ++ } + $path = $appPath . "/img/$fileName.svg"; + return $this->getSvg($path, $color, $fileName); + } -- GitLab From cf54ec50a16a47bd595a70af879983b12f4b8f41 Mon Sep 17 00:00:00 2001 From: akhil Date: Tue, 27 Jul 2021 20:45:11 +0530 Subject: [PATCH 2/5] Corrected the icons cacher patch --- patches/008-icons-cacher-theme-svgs.patch | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/patches/008-icons-cacher-theme-svgs.patch b/patches/008-icons-cacher-theme-svgs.patch index e1f0b232..a8e7c0fe 100644 --- a/patches/008-icons-cacher-theme-svgs.patch +++ b/patches/008-icons-cacher-theme-svgs.patch @@ -7,8 +7,8 @@ cache them instead of the icons in core or apps directories diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCacher-new.php --- ./lib/private/Template/IconsCacher.php 2021-07-22 18:05:40.133856200 +0530 -+++ ./lib/private/Template/IconsCacher-new.php 2021-07-22 18:08:31.650437441 +0530 -@@ -161,17 +161,26 @@ ++++ ./lib/private/Template/IconsCacher-new.php 2021-07-27 20:43:14.122338212 +0530 +@@ -161,17 +161,24 @@ $location = ''; $color = ''; $base = $this->getRoutePrefix() . '/svg/'; @@ -19,22 +19,21 @@ diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCa $cleanUrl = \substr($cleanUrl, \strlen('core')); if (\preg_match('/\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) { - list(,$cleanUrl,$color) = $matches; +- $location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg'; + list(,$cleanUrl,$color) = $matches; + $location = \OC::$SERVERROOT . '/themes/'. $theme . '/core/img/' . $cleanUrl . '.svg'; + if(!file_exists($location)){ + $location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg'; + } - $location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg'; } } elseif (\strpos($url, $base) === 0) { if (\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) { list(,$app,$cleanUrl, $color) = $matches; - $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; -+ $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; + $location = \OC::$SERVERROOT . '/themes/' . $theme . '/apps/' . $app . '/img/' . $cleanUrl . '.svg'; + if(!file_exists($location)) { + $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; + } if ($app === 'settings') { $location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg'; - } + } \ No newline at end of file -- GitLab From db66e718bb2eb94cd46f410ded69862af853b6b6 Mon Sep 17 00:00:00 2001 From: akhil Date: Tue, 27 Jul 2021 20:56:59 +0530 Subject: [PATCH 3/5] Fixed icons cacher patch again --- patches/008-icons-cacher-theme-svgs.patch | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/patches/008-icons-cacher-theme-svgs.patch b/patches/008-icons-cacher-theme-svgs.patch index a8e7c0fe..3a1aac74 100644 --- a/patches/008-icons-cacher-theme-svgs.patch +++ b/patches/008-icons-cacher-theme-svgs.patch @@ -8,7 +8,7 @@ cache them instead of the icons in core or apps directories diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCacher-new.php --- ./lib/private/Template/IconsCacher.php 2021-07-22 18:05:40.133856200 +0530 +++ ./lib/private/Template/IconsCacher-new.php 2021-07-27 20:43:14.122338212 +0530 -@@ -161,17 +161,24 @@ +@@ -161,20 +161,27 @@ $location = ''; $color = ''; $base = $this->getRoutePrefix() . '/svg/'; @@ -30,10 +30,16 @@ diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCa if (\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) { list(,$app,$cleanUrl, $color) = $matches; - $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; +- if ($app === 'settings') { +- $location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg'; +- } + $location = \OC::$SERVERROOT . '/themes/' . $theme . '/apps/' . $app . '/img/' . $cleanUrl . '.svg'; -+ if(!file_exists($location)) { ++ if(!file_exists($location)) { + $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; -+ } - if ($app === 'settings') { - $location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg'; - } \ No newline at end of file ++ if ($app === 'settings') { ++ $location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg'; ++ } ++ } + } + } + return [ -- GitLab From 28bf8359f7fb024975350a0f3cc22cc6274ecd6a Mon Sep 17 00:00:00 2001 From: akhil Date: Thu, 29 Jul 2021 00:06:36 +0530 Subject: [PATCH 4/5] Added patch to remove external site results from navigation --- Dockerfile | 1 + ...emove-external-sites-from-navigation.patch | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 patches/009-remove-external-sites-from-navigation.patch diff --git a/Dockerfile b/Dockerfile index e5a33eb1..5afc59f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,6 +85,7 @@ RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/006-recovery-email-changes.pa RUN patch -u ${BASE_DIR}/apps/settings/lib/Settings/Personal/ServerDevNotice.php -i ${TMP_PATCH_DIR}/007-remove-dev-notice.patch RUN patch -u ${BASE_DIR}/lib/private/Template/IconsCacher.php -i ${TMP_PATCH_DIR}/008-icons-cacher-theme-svgs.patch RUN patch -u ${BASE_DIR}/core/Controller/SvgController.php -i ${TMP_PATCH_DIR}/008-svg-controller-theme-svgs.patch +RUN patch -u ${BASE_DIR}/lib/private/TemplateLayout.php -i ${TMP_PATCH_DIR}/009-remove-external-sites-from-navigation.patch RUN rm -rf ${TMP_PATCH_DIR} # autocomplete leak tweak apps frontend with sed, disable group suggestion diff --git a/patches/009-remove-external-sites-from-navigation.patch b/patches/009-remove-external-sites-from-navigation.patch new file mode 100644 index 00000000..921fb9d2 --- /dev/null +++ b/patches/009-remove-external-sites-from-navigation.patch @@ -0,0 +1,22 @@ +From: Akhil +Date: Tue, 28 Jul 2021 21:25:00 +0530 +Subject: [PATCH] Removes external results from navigation + +This patch removes external link results from navigation. External link results are those coming from the +"external sites" app + +diff --git ./lib/private/TemplateLayout.php ./lib/private/TemplateLayout-new.php +--- ./lib/private/TemplateLayout.php 2021-07-28 21:20:30.155868957 +0530 ++++ ./lib/private/TemplateLayout-new.php 2021-07-28 21:22:34.387950470 +0530 +@@ -106,6 +106,11 @@ + $this->assign('appid', $appId); + + $navigation = $this->navigationManager->getAll(); ++ $navigation = array_filter($navigation, function($entry) { ++ if (strpos($entry["id"], "external_index") !== 0) { ++ return true; ++ } ++ }); + $this->assign('navigation', $navigation); + $settingsNavigation = $this->navigationManager->getAll('settings'); + $this->assign('settingsnavigation', $settingsNavigation); -- GitLab From 1a71af51d83b2c3b4160b691bc9e4c3a52d958b1 Mon Sep 17 00:00:00 2001 From: akhil Date: Thu, 29 Jul 2021 00:13:07 +0530 Subject: [PATCH 5/5] Added patch to remove external site entries from Navigation --- ...emove-external-sites-from-navigation.patch | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/patches/009-remove-external-sites-from-navigation.patch b/patches/009-remove-external-sites-from-navigation.patch index 921fb9d2..6b359727 100644 --- a/patches/009-remove-external-sites-from-navigation.patch +++ b/patches/009-remove-external-sites-from-navigation.patch @@ -6,17 +6,19 @@ This patch removes external link results from navigation. External link results "external sites" app diff --git ./lib/private/TemplateLayout.php ./lib/private/TemplateLayout-new.php ---- ./lib/private/TemplateLayout.php 2021-07-28 21:20:30.155868957 +0530 -+++ ./lib/private/TemplateLayout-new.php 2021-07-28 21:22:34.387950470 +0530 -@@ -106,6 +106,11 @@ - $this->assign('appid', $appId); +--- ./lib/private/TemplateLayout.php 2021-07-29 00:10:10.515495166 +0530 ++++ ./lib/private/TemplateLayout-new.php 2021-07-29 00:10:27.873160383 +0530 +@@ -105,7 +105,12 @@ + $this->assign('application', ''); + $this->assign('appid', $appId); - $navigation = $this->navigationManager->getAll(); +- $navigation = $this->navigationManager->getAll(); ++ $navigation = $this->navigationManager->getAll(); + $navigation = array_filter($navigation, function($entry) { -+ if (strpos($entry["id"], "external_index") !== 0) { -+ return true; -+ } ++ if (strpos($entry["id"], "external_index") !== 0) { ++ return true; ++ } + }); - $this->assign('navigation', $navigation); - $settingsNavigation = $this->navigationManager->getAll('settings'); - $this->assign('settingsnavigation', $settingsNavigation); + $this->assign('navigation', $navigation); + $settingsNavigation = $this->navigationManager->getAll('settings'); + $this->assign('settingsnavigation', $settingsNavigation); -- GitLab