Skip to content

Commit 39f771a

Browse files
committed
Fix string test and change unicode to character in backend
1 parent 9ae1369 commit 39f771a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

claripy/backends/backend_z3.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numbers
66
import operator
77
import os
8+
import re
89
import signal
910
import sys
1011
import threading
@@ -574,6 +575,19 @@ def _abstract_internal(self, ctx, ast, split_on=None):
574575
z3.Z3_inc_ref(ctx, ast)
575576
return a
576577

578+
def replace_unicode(self, match):
579+
"""
580+
Converts a Unicode escape sequence to the corresponding character.
581+
582+
Args:
583+
- match (re.Match): A regex match object containing a Unicode escape sequence.
584+
585+
Returns:
586+
- str: The Unicode character corresponding to the hexadecimal code.
587+
"""
588+
hex_code = match.group(1)
589+
return chr(int(hex_code, 16))
590+
577591
def _abstract_to_primitive(self, ctx, ast):
578592
decl = z3.Z3_get_app_decl(ctx, ast)
579593
decl_num = z3.Z3_get_decl_kind(ctx, decl)
@@ -629,7 +643,7 @@ def _abstract_to_primitive(self, ctx, ast):
629643
elif op_name == "INTERNAL":
630644
seq = z3.SeqRef(ast)
631645
if seq.is_string():
632-
return seq.as_string()
646+
return re.sub(r"\\u\{([0-9a-fA-F]+)\}", self.replace_unicode, seq.as_string())
633647
raise BackendError("Unable to abstract Z3 object to primitive")
634648

635649
def _abstract_bv_val(self, ctx, ast):

0 commit comments

Comments
 (0)