@@ -195,7 +195,7 @@ def __init__(self, table: Table, node: Node):
195195 self ._get_tag_field = lru_cache (4096 )(self ._get_tag_field )
196196 self ._find_tag_field_idx = lru_cache (4096 )(self ._find_tag_field_idx )
197197
198- def get (self , column : Column , raw : bool = False ) -> RecordValue :
198+ def get (self , column : Column , raw : bool = False , errors : str | None = "backslashreplace" ) -> RecordValue :
199199 """Retrieve the value for the specified column.
200200
201201 Optionally receive the raw data as it's stored in the record.
@@ -206,6 +206,7 @@ def get(self, column: Column, raw: bool = False) -> RecordValue:
206206 Args:
207207 column: The column to retrieve the value of.
208208 raw: Whether to return the raw data stored in the record instead of the parsed value.
209+ errors: Error handling scheme to use when decoding bytes to text (default: 'backslashreplace').
209210 """
210211 value = None
211212 tag_field = None
@@ -228,11 +229,11 @@ def get(self, column: Column, raw: bool = False) -> RecordValue:
228229 return value
229230
230231 if value is not None :
231- return self ._parse_value (column , value , tag_field )
232+ return self ._parse_value (column , value , tag_field , errors )
232233
233234 return None
234235
235- def as_dict (self , raw : bool = False ) -> dict [str , RecordValue ]:
236+ def as_dict (self , raw : bool = False , errors : str | None = "backslashreplace" ) -> dict [str , RecordValue ]:
236237 """Serialize the record as a dictionary."""
237238 obj = {}
238239
@@ -251,21 +252,23 @@ def _iter_column_id() -> Iterator[Column]:
251252 column = self .table ._column_id_map [column_id ]
252253
253254 try :
254- obj [column .name ] = self .get (column , raw )
255+ obj [column .name ] = self .get (column , raw , errors )
255256 except Exception as e :
256257 obj [column .name ] = f"!ERROR! { e } "
257258
258259 return obj
259260
260- def _parse_value (self , column : Column , value : bytes , tag_field : TagField = None ) -> RecordValue :
261+ def _parse_value (
262+ self , column : Column , value : bytes , tag_field : TagField = None , errors : str | None = "backslashreplace"
263+ ) -> RecordValue :
261264 """Parse the raw value into the appropriate type.
262265
263266 For tagged columns, also interpret things like multi-values, separated and compressed data.
264267 """
265268 ctype = column .ctype
266269 parse_func = ctype .parse
267270 if column .is_text :
268- parse_func = functools .partial (ctype .parse , encoding = column .encoding )
271+ parse_func = functools .partial (ctype .parse , encoding = column .encoding , errors = errors )
269272
270273 if self .esedb .impacket_compat :
271274 if tag_field and tag_field .flags & TAGFLD_HEADER .Compressed :
0 commit comments