From adc2b0b094f8733472f1fb0d3d98122b88bfbc15 Mon Sep 17 00:00:00 2001 From: ema Date: Mon, 5 Jan 2026 13:37:01 +0800 Subject: [PATCH] Remove UTF-8 BOM before JSON detection Added logic to strip the UTF-8 BOM character from the start of the text before performing JSON format detection. This ensures that files with a BOM are correctly identified as JSON. --- .../QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs index aa7270b..6d29bf7 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Detectors/JSONDetector.cs @@ -36,6 +36,10 @@ public sealed class JSONDetector : IFormatDetector var span = text.AsSpan(); + // Remove UTF-8 BOM if present + if (span.Length > 0 && span[0] == '\uFEFF') + span = span.Slice(1); + // TrimStart int start = 0; while (start < span.Length && char.IsWhiteSpace(span[start]))