Improve XML version attribute regex in XMLDetector

Updated the XMLDetector regex to support both single and double quotes in the XML version attribute, improving compatibility with different XML declaration styles.
Now supports:
<?xml version="1.0"?>
<?xml version='1.0'?>
This commit is contained in:
ema
2025-12-18 16:19:23 +08:00
parent 91c6323be6
commit cea937c0d6

View File

@@ -21,7 +21,7 @@ namespace QuickLook.Plugin.TextViewer.Detectors;
public sealed class XMLDetector : IFormatDetector
{
internal Regex Signature { get; } = new(@"<\?xml\b[^>]*\bversion\s*=\s*""[^""]*""[^\?>]*\?>", RegexOptions.IgnoreCase);
internal Regex Signature { get; } = new(@"<\?xml\b[^>]*\bversion\s*=\s*(['""])[^'""]*\1[^\?>]*\?>", RegexOptions.IgnoreCase);
public string Name => "XML";