From 994819e8a0c740980b9ace091c1f5454cf67484d Mon Sep 17 00:00:00 2001 From: yinjianm Date: Sat, 18 Apr 2026 01:50:45 +0800 Subject: [PATCH] fix(clashmeta): handle associative arrays in block yaml export --- app/Protocols/ClashMeta.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/Protocols/ClashMeta.php b/app/Protocols/ClashMeta.php index cf7ef2b..6e57060 100644 --- a/app/Protocols/ClashMeta.php +++ b/app/Protocols/ClashMeta.php @@ -250,6 +250,25 @@ class ClashMeta extends AbstractProtocol foreach ($value as $item) { $prefix = str_repeat(' ', $indent) . '-'; if (is_array($item)) { + if (self::isAssocArray($item)) { + $isFirst = true; + foreach ($item as $key => $child) { + $keyPrefix = ($isFirst ? $prefix . ' ' : str_repeat(' ', $indent + 2)) . $key . ':'; + if (is_array($child)) { + if ($child === []) { + $lines[] = $keyPrefix . ' []'; + } else { + $lines[] = $keyPrefix; + $lines[] = rtrim(self::dumpYamlNode($child, $indent + 4), "\n"); + } + } else { + $lines[] = $keyPrefix . ' ' . self::dumpYamlScalar($child); + } + $isFirst = false; + } + continue; + } + if ($item === []) { $lines[] = $prefix . ' []'; continue;