MCPcopy Create free account
hub / github.com/Fadi002/de4py / decode_hex

Method decode_hex

de4py/engines/onyx/string_decoder.py:257–267  ·  view source on GitHub ↗
(m: re.Match)

Source from the content-addressed store, hash-verified

255 )
256
257 def decode_hex(m: re.Match) -> str:
258 content = m.group(1) or m.group(2)
259 try:
260 hex_bytes = bytes.fromhex(content.replace('\\x', ''))
261 decoded = hex_bytes.decode('utf-8', errors='replace')
262 # Only inline if result is clean ASCII — never put non-ASCII into source
263 if '\ufffd' not in decoded and decoded.isascii():
264 return repr(decoded)
265 except Exception:
266 pass
267 return m.group(0)
268
269 return pattern.sub(decode_hex, source)
270

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected