Skip to content

Commit 58e94a3

Browse files
features: string: better __str__ embedded whitespace
1 parent 93acf9f commit 58e94a3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
- dotnet: address unhandled exceptions with improved type checking #1230 @mike-hunhoff
7878
- fix import-to-ida script formatting #1208 @williballenthin
7979
- render: fix verbose rendering of scopes #1263 @williballenthin
80+
- show-features: better render strings with embedded whitespace #1267 @williballenthin
8081

8182
### capa explorer IDA Pro plugin
8283
- fix: display instruction items #1154 @mr-tz

capa/features/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ class String(Feature):
179179
def __init__(self, value: str, description=None):
180180
super().__init__(value, description=description)
181181

182+
def get_value_str(self) -> str:
183+
return escape_string(self.value)
184+
182185

183186
class Class(Feature):
184187
def __init__(self, value: str, description=None):
@@ -232,9 +235,12 @@ def evaluate(self, ctx, short_circuit=True):
232235
else:
233236
return Result(False, _MatchedSubstring(self, {}), [])
234237

238+
def get_value_str(self) -> str:
239+
return escape_string(self.value)
240+
235241
def __str__(self):
236242
assert isinstance(self.value, str)
237-
return "substring(%s)" % self.value
243+
return "substring(%s)" % escape_string(self.value)
238244

239245

240246
class _MatchedSubstring(Substring):

0 commit comments

Comments
 (0)