Skip to content

fix(scripts): save the .ps1 scripts as UTF-8 with a BOM so Windows PowerShell 5.1 loads them - #186

Closed
jazzpher wants to merge 2 commits into
elementalsouls:mainfrom
jazzpher:fix/ps51-utf8-bom
Closed

jazzpher wants to merge 2 commits into
elementalsouls:mainfrom
jazzpher:fix/ps51-utf8-bom

Conversation

@jazzpher

Copy link
Copy Markdown

What does this change?

Fixes #183 (duplicate: #185). scripts/hunt.ps1, scripts/install.ps1 and scripts/install-community-skills.ps1 are saved as UTF-8 with a BOM. The text is unchanged — the em dashes and other non-ASCII characters stay exactly as they are.

Windows PowerShell 5.1 reads a .ps1 with no BOM in the system ANSI code page, so a UTF-8 em dash (E2 80 94) is decoded as —. In hunt.ps1 that lands inside a double-quoted string and the stray " ends the string early, so the whole file fails to parse. Because the file is dot-sourced from $PROFILE, every new PowerShell window throws parser errors and hunt is never defined. With a BOM, 5.1 decodes the file as UTF-8 and it parses cleanly. PowerShell 7 reads UTF-8 either way, so nothing changes there.

Reproduced on Windows PowerShell 5.1 by reading each file with [System.Text.Encoding]::Default and parsing it: 8 parser errors before, 0 after. hunt dot-sources and scaffolds correctly afterwards.

Type

  • New skill
  • Improvement to an existing skill
  • Docs / examples
  • Tooling / scripts / CI
  • Other:

Checklist

  • No client/engagement data — no real target names, account UIDs, endpoints, bounty amounts, credentials, or PII. All examples are class-based / anonymized.
  • python3 scripts/lint_skills.py passes locally (frontmatter, name, description length, identifier/secret scan).
  • For a new skill: a proposal issue was opened and agreed first; name is lowercase-hyphen; description ≤ 1024 chars and weaves in trigger keywords; body ≤ ~500 lines.
  • For a new skill: mentioned in README.md + USAGE.md decision tree, with one worked trigger example.
  • Sources cited for anything adapted from disclosed reports / community work.
  • Cross-references complementary skills ("see also …") where there's topical overlap.

Anything reviewers should know?

The powershell-smoke job already parses the scripts, but it runs on pwsh (PowerShell 7), which reads UTF-8 with or without a BOM — so it can never catch this class of bug. I added one step to that job that runs under shell: powershell (5.1 on windows-latest): it reads each file with Encoding.Default (the ANSI code page, as 5.1 does when there's no BOM), parses it with the PowerShell parser, then dot-sources hunt.ps1 and checks that hunt is defined. It fails on the current main and passes with this change.

No skill content, frontmatter or behaviour changes — only the three files' encoding plus that CI step. python3 -m pytest and scripts/lint_skills.py are unchanged and pass.

@jazzpher

Copy link
Copy Markdown
Author

Superseded by #192, which fixes #183 and #185 by making the scripts ASCII-only. Closing this one. Thanks!

@jazzpher jazzpher closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] hunt.ps1 breaks on Windows PowerShell 5.1 — em-dashes corrupted (no BOM)

1 participant