From 641f24347b4debcf95c9d6dd33719547d9ffa49c Mon Sep 17 00:00:00 2001 From: rihi <19492038+rihi@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:12:27 +0200 Subject: [PATCH] Revert _format_string_literal back --- decompiler/backend/cexpressiongenerator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/decompiler/backend/cexpressiongenerator.py b/decompiler/backend/cexpressiongenerator.py index aa1795c1..78afa82f 100644 --- a/decompiler/backend/cexpressiongenerator.py +++ b/decompiler/backend/cexpressiongenerator.py @@ -408,7 +408,10 @@ def _format_string_literal(constant: expressions.Constant) -> str: string_representation = str(constant) if string_representation.startswith('"') and string_representation.endswith('"'): string_representation = str(constant)[1:-1] - return f"{string_representation.translate(CExpressionGenerator.ESCAPE_TABLE)}" + if '"' in string_representation: + escaped = string_representation.replace('"', '\\"').translate(CExpressionGenerator.ESCAPE_TABLE) + return f'"{escaped}"' + return f"{constant}" @staticmethod def format_variables_declaration(var_type: Type, var_names: list[str]) -> str: