Sweep all .cshtml files for encoding corruption; add pre-commit guard
Replace all corruption variants with HTML entities across 226 view files: - 3-char UTF-8-as-Win1252 sequences (ae-corruption) - Standalone smart/curly quotes that break C# Razor expressions - Partially re-corrupted variants where the 3rd byte was normalised to ASCII tools/Fix-Encoding.ps1: re-runnable sweep; uses [char] code points so the script itself never contains a literal non-ASCII character; supports -DryRun .githooks/pre-commit: blocks commits containing the ae-corruption byte signature (xc3xa2xe2x82xac); git core.hooksPath = .githooks so the hook is repo-committed and active for all future work on this machine. Build clean; 225 unit tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Pre-commit hook: block commits containing corrupted Unicode in .cshtml files.
|
||||
#
|
||||
# All corruption variants start with the UTF-8 byte sequence for a-circumflex
|
||||
# followed by euro-sign (bytes C3 A2 E2 82 AC), which is the first two chars
|
||||
# of every known corruption pattern. Grep for that byte sequence in staged files.
|
||||
|
||||
STAGED=$(git diff --cached --name-only | grep '\.cshtml$')
|
||||
if [ -z "$STAGED" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# $'\xc3\xa2\xe2\x82\xac' = UTF-8 bytes for a-circumflex + euro-sign
|
||||
CORRUPT=$(echo "$STAGED" | xargs grep -l $'\xc3\xa2\xe2\x82\xac' 2>/dev/null)
|
||||
|
||||
if [ -n "$CORRUPT" ]; then
|
||||
echo ""
|
||||
echo "ERROR: Corrupted Unicode characters detected in staged .cshtml files:"
|
||||
echo "$CORRUPT" | sed 's/^/ /'
|
||||
echo ""
|
||||
echo "Fix by running: .\\tools\\Fix-Encoding.ps1"
|
||||
echo "Then re-stage the files and commit again."
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user