-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: strip leading BOM before SKILL.md frontmatter detection #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
709823e
a285218
db3068a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1575,6 +1575,15 @@ def _check_runtime() -> None: | |
| runtime_limit=runtime_limit, | ||
| ) | ||
| return {} | ||
| while content.startswith("\ufeff"): | ||
| # decode_text() decodes with plain "utf-8", which never strips a | ||
| # leading byte-order mark (only "utf-8-sig" does), so a BOM-prefixed | ||
| # SKILL.md leaves content[0] == "\ufeff" and the delimiter check below | ||
| # silently sees {} instead of the frontmatter. Strip leading BOMs here, | ||
| # scoped to delimiter detection — decode_text() itself stays untouched | ||
| # because P2/TP1/P9 treat U+FEFF as a hidden-character injection signal | ||
| # in file bodies. | ||
| content = content[1:] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny simplification: for this string case, One caution though: do NOT make the equivalent change to the bytes loop in |
||
| if not content.startswith("---"): | ||
| return {} | ||
| end_match = re.search(r"\n---\s*\n", content[3:]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description says "both places that sniff SKILL.md frontmatter", but I found a third:
_frontmatter_boundsinstatic_patterns_excessive_agency.py(around line 189) doesre.match(r"\A---[ \t]*\r?\n", content)ondecode_text()output, which keeps the BOM.I ran it: with plain frontmatter it returns bounds
(4, 17); add a leading BOM and it returnsNone. So EA5's frontmatter-key detection (model-switch keys,selection_surface: "frontmatter") still silently loses findings on a BOM-prefixed SKILL.md — the same silent-miss class this PR fixes.It's the same one-line class of fix, so worth either adding it here or filing a named follow-up, so the "both places" claim doesn't get taken at face value.