Compare commits

...

13 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
d6de335da5 Add trailing newline to ExtensionFilterHelper.cs
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
2025-11-26 21:23:11 +00:00
copilot-swe-agent[bot]
eade320211 Address code review: optimize directory checks and use static separator array
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
2025-11-26 21:21:36 +00:00
copilot-swe-agent[bot]
f54f037b01 Address code review feedback: improve docs and remove redundant I/O
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
2025-11-26 21:16:22 +00:00
copilot-swe-agent[bot]
15ec6b4749 Add ExtensionFilterHelper to main QuickLook project
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
2025-11-26 21:14:29 +00:00
copilot-swe-agent[bot]
0d9e80eb36 Add ExtensionFilterHelper and integrate with ViewWindowManager
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
2025-11-26 21:12:50 +00:00
copilot-swe-agent[bot]
b0dae69889 Initial plan 2025-11-26 21:06:21 +00:00
ema
76dfa34928 Update NuGet package versions in project files
Some checks failed
MSBuild / build (push) Has been cancelled
MSBuild / publish (push) Has been cancelled
Upgraded several NuGet dependencies across multiple csproj files, including Microsoft.Web.WebView2, Google.Protobuf, MsgReader, bblanchon.PDFiumV8.Win32, and Lib.Harmony. This ensures compatibility with the latest features and bug fixes from upstream packages.
2025-11-26 01:07:28 +08:00
Copilot
bf7de3bd8e Add ShowInTaskbar setting to display window in taskbar (#1818) 2025-11-26 00:52:12 +08:00
Copilot
1adb7ce980 Add option to disable automatic update check at startup (#1819) 2025-11-26 00:45:15 +08:00
copilot-swe-agent[bot]
d7edd92204 Fix DOpus crash when QuickLook runs with different privilege level 2025-11-25 23:49:22 +08:00
Copilot
cbf3e566d9 Fix volume control exceeding limits during mouse wheel scroll (#1814)
Some checks failed
MSBuild / build (push) Has been cancelled
MSBuild / publish (push) Has been cancelled
* Fix mouse scroll volume adjustment by clamping value to valid range [0.0, 1.0]
2025-11-25 00:18:36 +08:00
ema
f41fb0a68e Fix warning ColorProfile reference in ImageMagickProvider
Some checks failed
MSBuild / build (push) Has been cancelled
MSBuild / publish (push) Has been cancelled
QuickLook\QuickLook.Plugin\QuickLook.Plugin.ImageViewer\AnimatedImage\Providers\ImageMagickProvider.cs(112,35,112,52): warning CS0618: 'ColorProfile.SRGB' is obsolete: 'This property will be removed in the next major release. Use ColorProfiles.SRGB instead.'

Revert "Fix wwarning ColorProfile reference in ImageMagickProvider"

This reverts commit 649fd3a892.

Reapply "Fix wwarning ColorProfile reference in ImageMagickProvider"

This reverts commit 5e9dea6af313ec03c40b1f4dcaa461643a02d4f2.
2025-11-21 00:38:01 +08:00
Copilot
1f96cf5745 Add Svelte syntax highlighting support (#1809) 2025-11-20 00:01:34 +08:00
16 changed files with 466 additions and 21 deletions

View File

@@ -30,7 +30,7 @@
HWND hMsgWnd;
HANDLE hGetResultEvent;
PCHAR pXmlBuffer;
PCHAR pXmlBuffer = nullptr;
void DOpus::GetSelected(PWCHAR buffer)
{
@@ -72,9 +72,12 @@ void DOpus::GetSelected(PWCHAR buffer)
WaitForSingleObject(hGetResultEvent, 2000);
ParseXmlBuffer(buffer);
delete[] pXmlBuffer;
if (pXmlBuffer != nullptr)
{
ParseXmlBuffer(buffer);
delete[] pXmlBuffer;
pXmlBuffer = nullptr;
}
}
void DOpus::ParseXmlBuffer(PWCHAR buffer)
@@ -88,6 +91,9 @@ void DOpus::ParseXmlBuffer(PWCHAR buffer)
* ...
*/
if (pXmlBuffer == nullptr)
return;
using namespace rapidxml;
xml_document<> doc;

View File

@@ -73,7 +73,7 @@
<ItemGroup>
<PackageReference Include="FreeTypeSharp" Version="3.0.1" />
<PackageReference Include="QuickLook.Typography.OpenFont" Version="1.0.1" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3537.50">
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3595.46">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

View File

@@ -61,7 +61,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3537.50">
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3595.46">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

View File

@@ -109,7 +109,7 @@ internal class ImageMagickProvider : AnimationProvider
{
if (mi.ColorSpace == ColorSpace.RGB || mi.ColorSpace == ColorSpace.sRGB || mi.ColorSpace == ColorSpace.scRGB)
{
mi.SetProfile(ColorProfile.SRGB);
mi.SetProfile(ColorProfiles.SRGB);
if (ContextObject.ColorProfileName != null)
mi.SetProfile(new ColorProfile(ContextObject.ColorProfileName)); // map to monitor color
}

View File

@@ -62,10 +62,10 @@
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.9.1">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3537.50">
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3595.46">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Google.Protobuf" Version="3.33.0">
<PackageReference Include="Google.Protobuf" Version="3.33.1">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Memory" Version="4.6.3">

View File

@@ -55,7 +55,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MsgReader" Version="6.0.5" />
<PackageReference Include="MsgReader" Version="6.0.6" />
</ItemGroup>
<ItemGroup>

View File

@@ -61,7 +61,7 @@
<ItemGroup>
<PackageReference Include="UTF.Unknown" Version="2.6.0" />
<Reference Include="WindowsBase" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3537.50">
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3595.46">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

View File

@@ -64,7 +64,7 @@
<ItemGroup>
<PackageReference Include="PdfiumViewer.Updated" Version="2.14.5" />
<PackageReference Include="bblanchon.PDFiumV8.Win32" Version="143.0.7497" />
<PackageReference Include="bblanchon.PDFiumV8.Win32" Version="144.0.7543" />
<Reference Include="WindowsBase" />
</ItemGroup>

View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<SyntaxDefinition name="Svelte" extensions=".svelte" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="#6A9955" />
<Color name="Tag" foreground="#569CD6" exampleText="div" />
<Color name="Attribute" foreground="#9CDCFE" exampleText="on:click" />
<Color name="String" foreground="#CE9178" exampleText="&quot;text&quot;" />
<Color name="Directive" foreground="#DCDCAA" exampleText="bind:" />
<Color name="Keyword" foreground="#C586C0" exampleText="import" />
<Color name="Script" foreground="#D4D4D4" />
<Color name="Style" foreground="#4EC9B0" />
<RuleSet name="Html">
<Span color="Comment" begin="&lt;!--" end="--&gt;" />
<Span color="String" begin="&quot;" end="&quot;" />
<Span color="String" begin="&apos;" end="&apos;" />
<!-- Tags -->
<Span color="Tag" begin="&lt;" end="&gt;">
<RuleSet>
<Keywords color="Tag">
<Word>script</Word>
<Word>style</Word>
<Word>div</Word>
<Word>span</Word>
<Word>input</Word>
<Word>button</Word>
<Word>section</Word>
<Word>article</Word>
<Word>header</Word>
<Word>footer</Word>
<Word>main</Word>
<Word>nav</Word>
<Word>aside</Word>
<Word>p</Word>
<Word>h1</Word>
<Word>h2</Word>
<Word>h3</Word>
<Word>ul</Word>
<Word>li</Word>
<Word>a</Word>
<Word>img</Word>
</Keywords>
<Keywords color="Directive">
<Word>bind:</Word>
<Word>on:</Word>
<Word>use:</Word>
<Word>transition:</Word>
<Word>in:</Word>
<Word>out:</Word>
<Word>animate:</Word>
<Word>class:</Word>
<Word>style:</Word>
</Keywords>
<Keywords color="Attribute">
<Word>export</Word>
<Word>let</Word>
<Word>const</Word>
</Keywords>
</RuleSet>
</Span>
</RuleSet>
<RuleSet name="JavaScript">
<Span color="Comment" begin="//" end="\n" />
<Span color="Comment" begin="/\*" end="\*/" />
<Span color="String" begin="&quot;" end="&quot;" />
<Span color="String" begin="&apos;" end="&apos;" />
<Keywords color="Keyword">
<Word>import</Word>
<Word>export</Word>
<Word>default</Word>
<Word>return</Word>
<Word>const</Word>
<Word>let</Word>
<Word>var</Word>
<Word>if</Word>
<Word>else</Word>
<Word>for</Word>
<Word>while</Word>
<Word>function</Word>
<Word>async</Word>
<Word>await</Word>
<Word>new</Word>
<Word>this</Word>
<Word>true</Word>
<Word>false</Word>
<Word>null</Word>
<Word>undefined</Word>
<Word>each</Word>
<Word>if</Word>
<Word>else</Word>
<Word>await</Word>
<Word>then</Word>
<Word>catch</Word>
</Keywords>
</RuleSet>
<RuleSet name="CSS">
<Span color="Comment" begin="/\*" end="\*/" />
<Span color="String" begin="&quot;" end="&quot;" />
<Span color="String" begin="&apos;" end="&apos;" />
</RuleSet>
<RuleSet name="MainRuleSet">
<Import ruleSet="Html" />
<Import ruleSet="JavaScript" />
<Import ruleSet="CSS" />
</RuleSet>
<RuleSet>
<Import ruleSet="MainRuleSet" />
</RuleSet>
</SyntaxDefinition>

View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<SyntaxDefinition name="Svelte" extensions=".svelte" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="#008000" />
<Color name="Tag" foreground="#800000" exampleText="div" />
<Color name="Attribute" foreground="#0000FF" exampleText="on:click" />
<Color name="String" foreground="#A31515" exampleText="&quot;text&quot;" />
<Color name="Directive" foreground="#B000B0" exampleText="bind:" />
<Color name="Keyword" foreground="#000080" exampleText="import" />
<Color name="Script" foreground="#333333" />
<Color name="Style" foreground="#0055A5" />
<RuleSet name="Html">
<Span color="Comment" begin="&lt;!--" end="--&gt;" />
<Span color="String" begin="&quot;" end="&quot;" />
<Span color="String" begin="&apos;" end="&apos;" />
<!-- Tags -->
<Span color="Tag" begin="&lt;" end="&gt;">
<RuleSet>
<Keywords color="Tag">
<Word>script</Word>
<Word>style</Word>
<Word>div</Word>
<Word>span</Word>
<Word>input</Word>
<Word>button</Word>
<Word>section</Word>
<Word>article</Word>
<Word>header</Word>
<Word>footer</Word>
<Word>main</Word>
<Word>nav</Word>
<Word>aside</Word>
<Word>p</Word>
<Word>h1</Word>
<Word>h2</Word>
<Word>h3</Word>
<Word>ul</Word>
<Word>li</Word>
<Word>a</Word>
<Word>img</Word>
</Keywords>
<Keywords color="Directive">
<Word>bind:</Word>
<Word>on:</Word>
<Word>use:</Word>
<Word>transition:</Word>
<Word>in:</Word>
<Word>out:</Word>
<Word>animate:</Word>
<Word>class:</Word>
<Word>style:</Word>
</Keywords>
<Keywords color="Attribute">
<Word>export</Word>
<Word>let</Word>
<Word>const</Word>
</Keywords>
</RuleSet>
</Span>
</RuleSet>
<RuleSet name="JavaScript">
<Span color="Comment" begin="//" end="\n" />
<Span color="Comment" begin="/\*" end="\*/" />
<Span color="String" begin="&quot;" end="&quot;" />
<Span color="String" begin="&apos;" end="&apos;" />
<Keywords color="Keyword">
<Word>import</Word>
<Word>export</Word>
<Word>default</Word>
<Word>return</Word>
<Word>const</Word>
<Word>let</Word>
<Word>var</Word>
<Word>if</Word>
<Word>else</Word>
<Word>for</Word>
<Word>while</Word>
<Word>function</Word>
<Word>async</Word>
<Word>await</Word>
<Word>new</Word>
<Word>this</Word>
<Word>true</Word>
<Word>false</Word>
<Word>null</Word>
<Word>undefined</Word>
<Word>each</Word>
<Word>if</Word>
<Word>else</Word>
<Word>await</Word>
<Word>then</Word>
<Word>catch</Word>
</Keywords>
</RuleSet>
<RuleSet name="CSS">
<Span color="Comment" begin="/\*" end="\*/" />
<Span color="String" begin="&quot;" end="&quot;" />
<Span color="String" begin="&apos;" end="&apos;" />
</RuleSet>
<RuleSet name="MainRuleSet">
<Import ruleSet="Html" />
<Import ruleSet="JavaScript" />
<Import ruleSet="CSS" />
</RuleSet>
<RuleSet>
<Import ruleSet="MainRuleSet" />
</RuleSet>
</SyntaxDefinition>

View File

@@ -351,7 +351,7 @@ public partial class ViewerPanel : UserControl, IDisposable, INotifyPropertyChan
private void ChangeVolume(double delta)
{
LinearVolume += delta;
LinearVolume = Math.Max(0d, Math.Min(1d, LinearVolume + delta));
}
private void TogglePlayPause(object sender, EventArgs e)
@@ -385,16 +385,16 @@ public partial class ViewerPanel : UserControl, IDisposable, INotifyPropertyChan
UpdateMeta(path, info);
// detect rotation
double.TryParse(info?.Get(StreamKind.Video, 0, "Rotation"), out var rotation);
_ = double.TryParse(info?.Get(StreamKind.Video, 0, "Rotation"), out var rotation);
// Correct rotation: on some machine the value "90" becomes "90000" by some reason
if (rotation > 360)
if (rotation > 360d)
rotation /= 1e3;
if (Math.Abs(rotation) > 0.1)
mediaElement.LayoutTransform = new RotateTransform(rotation, 0.5, 0.5);
if (Math.Abs(rotation) > 0.1d)
mediaElement.LayoutTransform = new RotateTransform(rotation, 0.5d, 0.5d);
mediaElement.Source = new Uri(path);
// old plugin use an int-typed "Volume" config key ranged from 0 to 100. Let's use a new one here.
LinearVolume = SettingHelper.Get("VolumeDouble", 1d, "QuickLook.Plugin.VideoViewer");
LinearVolume = Math.Max(0d, Math.Min(1d, SettingHelper.Get("VolumeDouble", 1d, "QuickLook.Plugin.VideoViewer")));
mediaElement.Play();
}

View File

@@ -259,6 +259,9 @@ public partial class App : Application
private void CheckUpdate()
{
if (SettingHelper.Get("DisableAutoUpdateCheck", false))
return;
if (DateTime.Now.Ticks - SettingHelper.Get<long>("LastUpdateTicks") < TimeSpan.FromDays(30).Ticks)
return;

View File

@@ -0,0 +1,198 @@
// Copyright © 2017-2025 QL-Win Contributors
//
// This file is part of QuickLook program.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using QuickLook.Common.Helpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace QuickLook.Helpers;
/// <summary>
/// Helper class for managing file extension allowlist/blocklist filtering.
/// <para>
/// <b>Blocklist mode (default):</b> All extensions are allowed except those in the blocklist.
/// If the blocklist is empty, all files are allowed.
/// </para>
/// <para>
/// <b>Allowlist mode:</b> Only extensions in the allowlist can be previewed.
/// If the allowlist is empty in allowlist mode, all files are allowed (no filtering).
/// </para>
/// <para>
/// Directories and files without extensions are always allowed regardless of the mode.
/// </para>
/// </summary>
public static class ExtensionFilterHelper
{
private const string AllowlistKey = "ExtensionAllowlist";
private const string BlocklistKey = "ExtensionBlocklist";
private const string UseAllowlistModeKey = "UseExtensionAllowlistMode";
private static readonly char[] ExtensionSeparators = [';', ','];
private static HashSet<string> _allowlistCache;
private static HashSet<string> _blocklistCache;
private static bool? _useAllowlistModeCache;
/// <summary>
/// Gets or sets whether to use allowlist mode.
/// When true, only extensions in the allowlist can be previewed.
/// When false (default), extensions in the blocklist are blocked from preview.
/// </summary>
public static bool UseAllowlistMode
{
get
{
_useAllowlistModeCache ??= SettingHelper.Get(UseAllowlistModeKey, false);
return _useAllowlistModeCache.Value;
}
set
{
_useAllowlistModeCache = value;
SettingHelper.Set(UseAllowlistModeKey, value);
}
}
/// <summary>
/// Gets the current allowlist of file extensions.
/// Extensions should be in the format ".ext" (with leading dot).
/// </summary>
public static HashSet<string> Allowlist
{
get
{
if (_allowlistCache == null)
{
var list = SettingHelper.Get(AllowlistKey, string.Empty);
_allowlistCache = ParseExtensionList(list);
}
return _allowlistCache;
}
}
/// <summary>
/// Gets the current blocklist of file extensions.
/// Extensions should be in the format ".ext" (with leading dot).
/// </summary>
public static HashSet<string> Blocklist
{
get
{
if (_blocklistCache == null)
{
var list = SettingHelper.Get(BlocklistKey, string.Empty);
_blocklistCache = ParseExtensionList(list);
}
return _blocklistCache;
}
}
/// <summary>
/// Sets the allowlist of file extensions.
/// </summary>
/// <param name="extensions">Collection of extensions in the format ".ext" (with leading dot).</param>
public static void SetAllowlist(IEnumerable<string> extensions)
{
var normalized = NormalizeExtensions(extensions);
_allowlistCache = normalized;
SettingHelper.Set(AllowlistKey, string.Join(";", normalized));
}
/// <summary>
/// Sets the blocklist of file extensions.
/// </summary>
/// <param name="extensions">Collection of extensions in the format ".ext" (with leading dot).</param>
public static void SetBlocklist(IEnumerable<string> extensions)
{
var normalized = NormalizeExtensions(extensions);
_blocklistCache = normalized;
SettingHelper.Set(BlocklistKey, string.Join(";", normalized));
}
/// <summary>
/// Checks if a file path is allowed for preview based on the current filter settings.
/// </summary>
/// <param name="path">The file path to check.</param>
/// <returns>True if the file is allowed for preview, false if it should be blocked.</returns>
public static bool IsExtensionAllowed(string path)
{
if (string.IsNullOrEmpty(path))
return true;
var extension = Path.GetExtension(path);
// Files without extensions are always allowed (includes directories)
if (string.IsNullOrEmpty(extension))
return true;
extension = extension.ToLowerInvariant();
if (UseAllowlistMode)
{
// In allowlist mode: only allow if extension is in the allowlist
// If allowlist is empty, allow all (no filtering)
return Allowlist.Count == 0 || Allowlist.Contains(extension);
}
else
{
// In blocklist mode: block if extension is in the blocklist
return !Blocklist.Contains(extension);
}
}
/// <summary>
/// Clears the cached settings, forcing a reload from the config file.
/// </summary>
public static void ClearCache()
{
_allowlistCache = null;
_blocklistCache = null;
_useAllowlistModeCache = null;
}
private static HashSet<string> ParseExtensionList(string list)
{
if (string.IsNullOrWhiteSpace(list))
return new HashSet<string>(StringComparer.OrdinalIgnoreCase);
return new HashSet<string>(
list.Split(ExtensionSeparators, StringSplitOptions.RemoveEmptyEntries)
.Select(NormalizeExtension)
.Where(e => !string.IsNullOrEmpty(e)),
StringComparer.OrdinalIgnoreCase);
}
private static HashSet<string> NormalizeExtensions(IEnumerable<string> extensions)
{
return new HashSet<string>(
extensions.Select(NormalizeExtension).Where(e => !string.IsNullOrEmpty(e)),
StringComparer.OrdinalIgnoreCase);
}
private static string NormalizeExtension(string ext)
{
if (string.IsNullOrWhiteSpace(ext))
return null;
ext = ext.Trim().ToLowerInvariant();
if (!ext.StartsWith("."))
ext = "." + ext;
return ext;
}
}

View File

@@ -105,7 +105,7 @@
<PackageReference Include="WPF-UI.Violeta" Version="4.0.3.6">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Lib.Harmony" Version="2.4.1">
<PackageReference Include="Lib.Harmony" Version="2.4.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="UnblockZoneIdentifier" Version="1.0.0">

View File

@@ -151,10 +151,15 @@ public class ViewWindowManager : IDisposable
if (_viewerWindow.IsVisible && path == _invokedPath)
return;
if (!Directory.Exists(path) && !File.Exists(path))
var isDirectory = Directory.Exists(path);
if (!isDirectory && !File.Exists(path))
if (!path.StartsWith("::")) // CLSID
return;
// Check extension filtering before proceeding (skip for directories)
if (!isDirectory && !ExtensionFilterHelper.IsExtensionAllowed(path))
return;
_invokedPath = path;
RunFocusMonitor();
@@ -172,7 +177,12 @@ public class ViewWindowManager : IDisposable
if (string.IsNullOrEmpty(path))
return;
if (!Directory.Exists(path) && !File.Exists(path))
var isDirectory = Directory.Exists(path);
if (!isDirectory && !File.Exists(path))
return;
// Check extension filtering before proceeding (skip for directories)
if (!isDirectory && !ExtensionFilterHelper.IsExtensionAllowed(path))
return;
RunFocusMonitor();

View File

@@ -64,6 +64,8 @@ public partial class ViewerWindow : Window
Topmost = SettingHelper.Get("Topmost", false);
buttonTop.Tag = Topmost ? "Top" : "Auto";
ShowInTaskbar = SettingHelper.Get("ShowInTaskbar", false);
buttonTop.Click += (_, _) =>
{
Topmost = !Topmost;