Skip to content

Commit f4a21f0

Browse files
fix: use line-anchored scan for skills frontmatter delimiter
Replace raw split('---', 2) with line-anchored scan for the closing delimiter to prevent embedded --- values in descriptions from truncating metadata or spilling into the skill body.
1 parent c31e18d commit f4a21f0

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

  • src/specify_cli/integrations

‎src/specify_cli/integrations/base.py‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,10 +1630,18 @@ def setup(
16301630
# Parse frontmatter for description
16311631
frontmatter: dict[str, Any] = {}
16321632
if raw.startswith("---"):
1633-
parts = raw.split("---", 2)
1634-
if len(parts) >= 3:
1633+
fm_lines = raw.split("\n")
1634+
fm_close = next(
1635+
(
1636+
i
1637+
for i in range(1, len(fm_lines))
1638+
if fm_lines[i].rstrip() == "---"
1639+
),
1640+
None,
1641+
)
1642+
if fm_close is not None:
16351643
try:
1636-
fm = yaml.safe_load(parts[1])
1644+
fm = yaml.safe_load("\n".join(fm_lines[1:fm_close]))
16371645
if isinstance(fm, dict):
16381646
frontmatter = fm
16391647
except yaml.YAMLError:
@@ -1650,9 +1658,17 @@ def setup(
16501658
# output byte-for-byte (the template body starts with \n after
16511659
# the closing ---).
16521660
if processed_body.startswith("---"):
1653-
parts = processed_body.split("---", 2)
1654-
if len(parts) >= 3:
1655-
processed_body = parts[2]
1661+
body_lines = processed_body.split("\n")
1662+
body_close = next(
1663+
(
1664+
i
1665+
for i in range(1, len(body_lines))
1666+
if body_lines[i].rstrip() == "---"
1667+
),
1668+
None,
1669+
)
1670+
if body_close is not None:
1671+
processed_body = "\n".join(body_lines[body_close + 1 :])
16561672

16571673
# Select description — use the original template description
16581674
# to stay byte-for-byte identical with release ZIP output.

0 commit comments

Comments
 (0)