Skip to content

Commit

Permalink
Backport pull request #4654 from jellyfin/release-10.8.z
Browse files Browse the repository at this point in the history
Add confirmation for 3rd party repos

Original-merge: 331fa87

Merged-by: Bill Thornton <thornbill@users.noreply.github.com>

Backported-by: Bill Thornton <thornbill@users.noreply.github.com>
  • Loading branch information
joshuaboniface authored and thornbill committed Jul 2, 2023
1 parent 2ce9988 commit b372953
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/controllers/dashboard/plugins/add/index.html
Expand Up @@ -34,7 +34,9 @@ <h2 class="sectionTitle">${HeaderInstall}</h2>
<div class="readOnlyContent">
<div is="emby-collapse" title="${HeaderDeveloperInfo}">
<div class="collapseContent">
<p id="developer"></p>
<p>${LabelDeveloper}: <span id="developer"></span></p>
<p>${LabelRepositoryName}: <span id="repositoryName"></span></p>
<p>${LabelRepositoryUrl}: <span id="repositoryUrl"></span></p>
</div>
</div>

Expand Down
16 changes: 14 additions & 2 deletions src/controllers/dashboard/plugins/add/index.js
Expand Up @@ -64,6 +64,16 @@ function renderPackage(pkg, installedPlugins, page) {

$('#description', page).text(pkg.description);
$('#developer', page).text(pkg.owner);
// This is a hack; the repository name and URL should be part of the global values
// for the plugin, not each individual version. So we just use the top (latest)
// version to get this information. If it's missing (no versions), then say so.
if (pkg.versions.length) {
$('#repositoryName', page).text(pkg.versions[0].repositoryName);
$('#repositoryUrl', page).text(pkg.versions[0].repositoryUrl);
} else {
$('#repositoryName', page).text(globalize.translate('Unknown'));
$('#repositoryUrl', page).text(globalize.translate('Unknown'));
}

if (installedPlugin) {
const currentVersionText = globalize.translate('MessageYouHaveVersionInstalled', '<strong>' + installedPlugin.Version + '</strong>');
Expand All @@ -80,7 +90,7 @@ function alertText(options) {
}

function performInstallation(page, name, guid, version) {
const developer = $('#developer', page).html().toLowerCase();
const repositoryUrl = $('#repositoryUrl', page).html().toLowerCase();

const alertCallback = function () {
loading.show();
Expand All @@ -93,7 +103,9 @@ function performInstallation(page, name, guid, version) {
});
};

if (developer !== 'jellyfin') {
// Check the repository URL for the official Jellyfin repository domain, or
// present the warning for 3rd party plugins.
if (!repositoryUrl.startsWith('https://repo.jellyfin.org/')) {
loading.hide();
let msg = globalize.translate('MessagePluginInstallDisclaimer');
msg += '<br/>';
Expand Down
37 changes: 30 additions & 7 deletions src/controllers/dashboard/plugins/repositories/index.js
Expand Up @@ -2,6 +2,7 @@ import loading from '../../../../components/loading/loading';
import libraryMenu from '../../../../scripts/libraryMenu';
import globalize from '../../../../scripts/globalize';
import dialogHelper from '../../../../components/dialogHelper/dialogHelper';
import confirm from '../../../../components/confirm/confirm';

import '../../../../elements/emby-button/emby-button';
import '../../../../elements/emby-checkbox/emby-checkbox';
Expand Down Expand Up @@ -166,14 +167,36 @@ export default function(view) {
dialog.querySelector('.newPluginForm').addEventListener('submit', e => {
e.preventDefault();

repositories.push({
Name: dialog.querySelector('#txtRepositoryName').value,
Url: dialog.querySelector('#txtRepositoryUrl').value,
Enabled: true
});
const repositoryUrl = dialog.querySelector('#txtRepositoryUrl').value.toLowerCase();

const alertCallback = function () {
repositories.push({
Name: dialog.querySelector('#txtRepositoryName').value,
Url: dialog.querySelector('#txtRepositoryUrl').value,
Enabled: true
});
saveList(view);
dialogHelper.close(dialog);
};

// Check the repository URL for the official Jellyfin repository domain, or
// present the warning for 3rd party plugins.
if (!repositoryUrl.startsWith('https://repo.jellyfin.org/')) {
let msg = globalize.translate('MessageRepositoryInstallDisclaimer');
msg += '<br/>';
msg += '<br/>';
msg += globalize.translate('PleaseConfirmRepositoryInstallation');

confirm(msg, globalize.translate('HeaderConfirmRepositoryInstallation')).then(function () {
alertCallback();
}).catch(() => {
console.debug('repository not installed');
dialogHelper.close(dialog);
});
} else {
alertCallback();
}

saveList(view);
dialogHelper.close(dialog);
return false;
});

Expand Down
9 changes: 7 additions & 2 deletions src/strings/en-us.json
Expand Up @@ -337,6 +337,7 @@
"HeaderCodecProfileHelp": "Codec profiles indicate the limitations of a device when playing specific codecs. If a limitation applies then the media will be transcoded, even if the codec is configured for direct playback.",
"HeaderConfigureRemoteAccess": "Set up Remote Access",
"HeaderConfirmPluginInstallation": "Confirm Plugin Installation",
"HeaderConfirmRepositoryInstallation": "Confirm Plugin Repository Installation",
"HeaderConfirmProfileDeletion": "Confirm Profile Deletion",
"HeaderConfirmRevokeApiKey": "Revoke API Key",
"HeaderConnectionFailure": "Connection Failure",
Expand Down Expand Up @@ -612,6 +613,7 @@
"LabelDefaultUser": "Default user",
"LabelDefaultUserHelp": "Determine which user library should be displayed on connected devices. This can be overridden for each device using profiles.",
"LabelDeinterlaceMethod": "Deinterlacing method",
"LabelDeveloper": "Developer",
"LabelDeviceDescription": "Device description",
"LabelDidlMode": "DIDL mode",
"LabelDisableCustomCss": "Disable custom CSS code for theming/branding provided from the server.",
Expand Down Expand Up @@ -1099,11 +1101,12 @@
"MessagePleaseEnsureInternetMetadata": "Please ensure downloading of internet metadata is enabled.",
"MessagePleaseWait": "Please wait. This may take a minute.",
"MessagePluginConfigurationRequiresLocalAccess": "To set up this plugin please sign in to your local server directly.",
"MessagePluginInstallDisclaimer": "Plugins built by community members are a great way to enhance your experience with additional features and benefits. Before installing, please be aware of the effects they may have on your server, such as longer library scans, additional background processing, and decreased system stability.",
"MessagePluginInstallDisclaimer": "WARNING: Installing a third party plugin carries risks. It may contain unstable or malicious code, and may change at any time. Only install plugins from authors that you trust, and please be aware of the potential effects it may have, including external service queries, longer library scans, or additional background processing.",
"MessagePluginInstalled": "The plugin has been successfully installed. The server will need to be restarted for changes to take effect.",
"MessagePluginInstallError": "An error occurred while installing the plugin.",
"MessageReenableUser": "See below to reenable",
"MessageRenameMediaFolder": "Renaming a media library will cause all metadata to be lost, proceed with caution.",
"MessageRepositoryInstallDisclaimer": "WARNING: Installing a third party plugin repository carries risks. It may contain unstable or malicious code, and may change at any time. Only install repositories from authors that you trust.",
"MessageSent": "Message sent.",
"MessageSyncPlayCreateGroupDenied": "Permission required to create a group.",
"MessageSyncPlayDisabled": "SyncPlay disabled.",
Expand Down Expand Up @@ -1318,6 +1321,7 @@
"PlayNextEpisodeAutomatically": "Play next episode automatically",
"PleaseAddAtLeastOneFolder": "Please add at least one folder to this library by clicking the '+' button in 'Folders' section.",
"PleaseConfirmPluginInstallation": "Please click OK to confirm you've read the above and wish to proceed with the plugin installation.",
"PleaseConfirmRepositoryInstallation": "Please click OK to confirm you've read the above and wish to proceed with the plugin repository installation.",
"PleaseEnterNameOrId": "Please enter a name or an external ID.",
"PleaseRestartServerName": "Please restart Jellyfin on {0}.",
"PleaseSelectTwoItems": "Please select at least two items.",
Expand Down Expand Up @@ -1710,5 +1714,6 @@
"MediaInfoDvBlSignalCompatibilityId": "DV bl signal compatibility id",
"Unreleased": "Not yet released",
"LabelTonemappingMode": "Tone mapping mode",
"TonemappingModeHelp": "Select the tone mapping mode. If you experience blown out highlights try switching to the RGB mode."
"TonemappingModeHelp": "Select the tone mapping mode. If you experience blown out highlights try switching to the RGB mode.",
"Unknown": "Unknown"
}

0 comments on commit b372953

Please sign in to comment.