aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/PluginsController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Api/Controllers/PluginsController.cs')
-rw-r--r--Jellyfin.Api/Controllers/PluginsController.cs31
1 files changed, 25 insertions, 6 deletions
diff --git a/Jellyfin.Api/Controllers/PluginsController.cs b/Jellyfin.Api/Controllers/PluginsController.cs
index 79e6536fb6..2c84fde972 100644
--- a/Jellyfin.Api/Controllers/PluginsController.cs
+++ b/Jellyfin.Api/Controllers/PluginsController.cs
@@ -226,16 +226,35 @@ public class PluginsController : BaseJellyfinApiController
return NotFound();
}
- var imagePath = Path.Combine(plugin.Path, plugin.Manifest.ImagePath ?? string.Empty);
- if (plugin.Manifest.ImagePath is null || !System.IO.File.Exists(imagePath))
+ string? imagePath = plugin.Manifest.ImagePath;
+ if (!string.IsNullOrWhiteSpace(imagePath))
{
- return NotFound();
+ var pluginPath = Path.TrimEndingDirectorySeparator(Path.GetFullPath(plugin.Path));
+ imagePath = Path.GetFullPath(imagePath, pluginPath);
+ // Require a separator after the plugin path so a sibling like "<pluginPath>-evil" can't pass.
+ if (imagePath.StartsWith(pluginPath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) is false || System.IO.File.Exists(imagePath) is false)
+ {
+ return NotFound();
+ }
+
+ Response.Headers.ContentDisposition = "attachment";
+ return PhysicalFile(imagePath, MimeTypes.GetMimeType(imagePath));
}
- Response.Headers.ContentDisposition = "attachment";
+ var resourceName = plugin.Manifest.ImageResourceName;
+ if (!string.IsNullOrEmpty(resourceName) && plugin.Instance is not null)
+ {
+ var stream = plugin.Instance.GetType().Assembly.GetManifestResourceStream(resourceName);
+ if (stream is null)
+ {
+ return NotFound();
+ }
+
+ Response.Headers.ContentDisposition = "attachment";
+ return File(stream, MimeTypes.GetMimeType(resourceName));
+ }
- imagePath = Path.Combine(plugin.Path, plugin.Manifest.ImagePath);
- return PhysicalFile(imagePath, MimeTypes.GetMimeType(imagePath));
+ return NotFound();
}
/// <summary>