Skip to content

Commit

Permalink
fix: Allow to opt-in loading image mimes on hide download shares
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Aug 24, 2023
1 parent 9f7b3ce commit fe0c503
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class AppConfig {

public const READ_ONLY_FEATURE_LOCK = 'read_only_feature_lock';

// Load additional mime types (like images) on public share links when hide download is enabled
// Default: 'no', set to 'yes' to enable
public const USE_SECURE_VIEW_ADDITIONAL_MIMES = 'use_secure_view_additional_mimes';

private $defaults = [
'wopi_url' => '',
'timeout' => 15,
Expand Down Expand Up @@ -178,4 +182,8 @@ public function getWopiOverride(): array {
}
return [];
}

public function useSecureViewAdditionalMimes(): bool {
return $this->config->getAppValue(Application::APPNAME, self::USE_SECURE_VIEW_ADDITIONAL_MIMES, 'no') === 'yes';
}
}
22 changes: 21 additions & 1 deletion lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,26 @@ class Capabilities implements ICapability {
'image/svg+xml',
'application/pdf',
'text/plain',
'text/spreadsheet'
'text/spreadsheet',
];

public const SECURE_VIEW_ADDITIONAL_MIMES = [
'image/jpeg',
'image/svg+xml',
'image/cgm',
'image/vnd.dxf',
'image/x-emf',
'image/x-wmf',
'image/x-wpg',
'image/x-freehand',
'image/bmp',
'image/png',
'image/gif',
'image/tiff',
'image/jpg',
'image/jpeg',
'text/plain',
'application/pdf',
];

private IL10N $l10n;
Expand Down Expand Up @@ -124,6 +143,7 @@ public function getCapabilities() {
'version' => \OC::$server->getAppManager()->getAppVersion('richdocuments'),
'mimetypes' => array_values($filteredMimetypes),
'mimetypesNoDefaultOpen' => array_values($optionalMimetypes),
'mimetypesSecureView' => $this->config->useSecureViewAdditionalMimes() ? self::SECURE_VIEW_ADDITIONAL_MIMES : [],
'collabora' => $collaboraCapabilities,
'direct_editing' => isset($collaboraCapabilities['hasMobileSupport']) ?: false,
'templates' => isset($collaboraCapabilities['hasTemplateSaveAs']) || isset($collaboraCapabilities['hasTemplateSource']) ?: false,
Expand Down
2 changes: 1 addition & 1 deletion src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const odfViewer = {
|| (typeof OC.getCapabilities().richdocuments.collabora === 'object' && OC.getCapabilities().richdocuments.collabora.length !== 0)),
supportedMimes: OC.getCapabilities().richdocuments.mimetypes.concat(OC.getCapabilities().richdocuments.mimetypesNoDefaultOpen),
excludeMimeFromDefaultOpen: OC.getCapabilities().richdocuments.mimetypesNoDefaultOpen,
hideDownloadMimes: ['image/jpeg', 'image/svg+xml', 'image/cgm', 'image/vnd.dxf', 'image/x-emf', 'image/x-wmf', 'image/x-wpg', 'image/x-freehand', 'image/bmp', 'image/png', 'image/gif', 'image/tiff', 'image/jpg', 'image/jpeg', 'text/plain', 'application/pdf'],
hideDownloadMimes: OC.getCapabilities().richdocuments.mimetypesSecureView,

onEdit(fileName, context) {
let fileDir
Expand Down

0 comments on commit fe0c503

Please sign in to comment.