Skip to content

Commit 4668575

Browse files
vlydevVladyslav Lyshenko
authored andcommitted
fix: handle hex payloads whose first byte starts with 'A'
Previously, _extract_hex() would match _INSPECT_URL_RE and strip the leading 'A', treating it as the classic asset-ID prefix marker. When the XOR key byte encoded as hex 'A' (0xAx), this produced an odd-length hex string which caused binascii.unhexlify() to raise an error. Fix: add an even-length guard — if stripping 'A' yields an odd number of hex characters, 'A' is part of the payload. Fall through to the pure-masked regex which captures the full hex blob including the 'A'.
1 parent b67ac21 commit 4668575

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cs2_inspect/inspect_link.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ def _extract_hex(hex_or_url: str) -> str:
5757
if m and re.search(r'[A-Fa-f]', m.group(1)):
5858
return m.group(1)
5959

60-
# Classic/market URL: A<hex> preceded by %20, space, or + (A is a prefix marker, not hex)
60+
# Classic/market URL: A<hex> preceded by %20, space, or + (A is a prefix marker, not hex).
61+
# If stripping A yields odd-length hex, A is actually the first byte of the payload —
62+
# fall through to the pure-masked check below which captures it with A included.
6163
m = _INSPECT_URL_RE.search(stripped)
62-
if m:
64+
if m and len(m.group(1)) % 2 == 0:
6365
return m.group(1)
6466

65-
# Pure masked format: csgo_econ_action_preview%20<hexblob> (no S/A/M prefix)
67+
# Pure masked format: csgo_econ_action_preview%20<hexblob> (no S/A/M prefix).
68+
# Also handles payloads whose first hex character happens to be A.
6669
mm = re.search(r'csgo_econ_action_preview(?:%20|\s|\+)([0-9A-Fa-f]{10,})$', stripped, re.IGNORECASE)
6770
if mm:
6871
return mm.group(1)

0 commit comments

Comments
 (0)