Skip to content

Commit 41c1950

Browse files
committed
fix(contracts): canonicalize release bytes as LF
1 parent 12dcd6c commit 41c1950

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

.github/workflows/contract-registry-live.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
import hashlib, json, os, pathlib, urllib.request
2525
2626
def canonical_bytes(data: bytes) -> bytes:
27-
return data.replace(b"\r\n", b"\n").replace(b"\n", b"\r\n")
27+
return data.replace(b"\r\n", b"\n")
2828
2929
def sha256_hex(data: bytes) -> str:
30-
return hashlib.sha256(data).hexdigest()
30+
return hashlib.sha256(canonical_bytes(data)).hexdigest()
3131
3232
base = os.environ["REGISTRY_BASE"]
3333
version = os.environ["PINNED_VERSION"]

src/GsdOrchestrator.Tests/ContractCompatibilityTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private static JsonNode LoadSchema(string name) =>
4141
private static byte[] ReadCanonicalUtf8Bytes(string path)
4242
{
4343
var text = File.ReadAllText(path);
44-
var normalized = text.ReplaceLineEndings("\r\n");
44+
var normalized = text.ReplaceLineEndings("\n");
4545
return Encoding.UTF8.GetBytes(normalized);
4646
}
4747

@@ -133,7 +133,7 @@ public void VendoredRelease_MatchesManifestHashes()
133133
{
134134
var path = (string)entry!["path"]!;
135135
var expected = (string)entry["sha256"]!;
136-
var bytes = File.ReadAllBytes(Path.Combine(ContractRoot, path));
136+
var bytes = ReadCanonicalUtf8Bytes(Path.Combine(ContractRoot, path));
137137
var actual = Sha256Hex(bytes);
138138
Assert.Equal(expected, actual);
139139
}

0 commit comments

Comments
 (0)