Skip to content

Commit cc17d4e

Browse files
committed
Add version check for Chromium .pak files
Updated CanHandle to verify that .pak files are Chromium resource package version 5 before handling. This prevents unsupported v4 .pak files from being processed.
1 parent fd73421 commit cc17d4e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/Plugin.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public sealed partial class Plugin : IViewer, IMoreMenu
5858
".eif", // QQ emoji file (Compound File Binary format)
5959

6060
// List of supported chromium resource package file extensions
61-
".pak", // Chromium resource package file, used by Chromium-based applications (e.g., Google Chrome)
61+
".pak", // Chromium resource package file v5, used by Chromium-based applications (e.g., Google Chrome)
6262
];
6363

6464
private IDisposable _panel;
@@ -74,7 +74,31 @@ public void Init()
7474

7575
public bool CanHandle(string path)
7676
{
77-
return !Directory.Exists(path) && _extensions.Any(path.ToLower().EndsWith);
77+
if (Directory.Exists(path))
78+
return false;
79+
80+
if (path.EndsWith(".pak", StringComparison.OrdinalIgnoreCase))
81+
{
82+
// Chromium PAK files usually start with header as version
83+
try
84+
{
85+
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
86+
using var br = new BinaryReader(fs);
87+
var version = br.ReadUInt32();
88+
89+
// Check for Chromium PAK version
90+
// if v5 → PASS
91+
// if v4 → FAIL (NOT Supported)
92+
if (version == 5) return true;
93+
}
94+
catch
95+
{
96+
// Ignore file read errors, treat as not handled
97+
}
98+
return false;
99+
}
100+
101+
return _extensions.Any(ext => path.EndsWith(ext, StringComparison.OrdinalIgnoreCase));
78102
}
79103

80104
public void Prepare(string path, ContextObject context)

SUPPORTED_FORMATS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ Update not completed yet...
215215
- `.zip` (ZIP archive)
216216
- `.cfb` (Compound File Binary)
217217
- `.eif` (QQ EIF package with Compound File Binary format)
218+
- `.pak` (Chromium resource package file v5, used by Chromium-based applications (e.g., Google Chrome))
218219

219220
### Markdown files
220221
- `.md`, `.markdown` (Markdown)

0 commit comments

Comments
 (0)