File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # Normalize line endings to LF in the repo. Prevents the CRLF churn that shows
2- # up on Windows clones and stops CP-1252 control bytes (e.g. 0x97 em-dash) from
3- # silently breaking UTF-8 tools like zizmor.
1+ # Line-ending + binary policy.
2+ # text=auto detects text and normalizes it to LF in the repo (kills the CRLF
3+ # churn that shows up on Windows clones); explicit eol for scripts that need a
4+ # fixed ending; binary markers so git never line-ending-munges non-text files.
5+ # Refs: https://git-scm.com/docs/gitattributes
6+ # https://docs.github.com/en/get-started/git-basics/configuring-git-to-handle-line-endings
47* text =auto eol =lf
8+
9+ # Windows scripts must keep CRLF (cmd.exe).
10+ * .bat text eol =crlf
11+ * .cmd text eol =crlf
12+
13+ # Binary — never normalize.
14+ * .png binary
15+ * .jpg binary
16+ * .jpeg binary
17+ * .gif binary
18+ * .ico binary
19+ * .webp binary
20+ * .woff binary
21+ * .woff2 binary
22+ * .pdf binary
23+ * .zip binary
Original file line number Diff line number Diff line change @@ -19,21 +19,25 @@ jobs:
1919 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2020 with :
2121 persist-credentials : false
22- - name : Validate UTF-8 (catches CP-1252 0x97 that silently breaks zizmor)
22+ - name : Validate UTF-8 (binary-safe; catches CP-1252 0x97 that breaks zizmor)
2323 run : |
2424 python3 - <<'PY'
2525 import pathlib, sys
2626 bad = []
2727 for p in pathlib.Path(".github").rglob("*"):
28- if p.is_file():
29- try:
30- p.read_bytes().decode("utf-8")
31- except UnicodeDecodeError as e:
32- bad.append(f"{p}: {e}")
28+ if not p.is_file():
29+ continue
30+ data = p.read_bytes()
31+ if b"\x00" in data: # binary file (git's own heuristic) -> skip
32+ continue
33+ try:
34+ data.decode("utf-8")
35+ except UnicodeDecodeError as e:
36+ bad.append(f"{p}: {e}")
3337 if bad:
3438 print("::error::Invalid UTF-8 (e.g. CP-1252 0x97) found in .github/:")
3539 for b in bad:
3640 print(" " + b)
3741 sys.exit(1)
38- print("OK: all .github files are valid UTF-8.")
42+ print("OK: all text files in .github/ are valid UTF-8.")
3943 PY
You can’t perform that action at this time.
0 commit comments