native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Accept unpadded Sparkle base64 key

khoi 8cca369a e7df6cfe

+15 -4
+15 -4
.github/workflows/release.yml
··· 133 133 SPARKLE_KEY_B64=$(python3 - <<'PY' 134 134 import os, base64, re, binascii, sys 135 135 key = os.environ.get("SPARKLE_PRIVATE_KEY", "") 136 - key = key.strip().replace("\n", "").replace("\r", "") 136 + key = key.strip() 137 + if "BEGIN" in key: 138 + key = re.sub(r"-----BEGIN[^-]*-----", "", key) 139 + key = re.sub(r"-----END[^-]*-----", "", key) 140 + key = re.sub(r"\s+", "", key) 137 141 if not key: 138 142 sys.exit("SPARKLE_PRIVATE_KEY is empty") 139 143 if re.fullmatch(r"[0-9a-fA-F]{128}", key): 140 144 raw = binascii.unhexlify(key) 141 145 print(base64.b64encode(raw).decode()) 142 146 sys.exit(0) 143 - try: 144 - raw = base64.b64decode(key, validate=True) 145 - except Exception: 147 + def decode_b64(value): 148 + value = value.replace("-", "+").replace("_", "/") 149 + if len(value) % 4: 150 + value += "=" * (4 - (len(value) % 4)) 151 + try: 152 + return base64.b64decode(value, validate=True) 153 + except Exception: 154 + return None 155 + raw = decode_b64(key) 156 + if raw is None: 146 157 sys.exit("SPARKLE_PRIVATE_KEY is not valid base64 or hex") 147 158 if len(raw) not in (32, 64): 148 159 sys.exit(f"SPARKLE_PRIVATE_KEY decoded length {len(raw)} is not 32 or 64")