Skip to content

Commit e1ddfe6

Browse files
authored
[fix] Fix invisible chars in error plist (#4809)
When either the standard input/output or compilation command contains an invisible character then plist dump fails.
1 parent 5ddfd72 commit e1ddfe6

File tree

1 file changed

+10
-3
lines changed
  • tools/report-converter/codechecker_report_converter/report

1 file changed

+10
-3
lines changed

tools/report-converter/codechecker_report_converter/report/error_file.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
from codechecker_report_converter.report.parser import plist
1212

1313

14+
def convert_to_printable(text: str) -> str:
15+
"""Convert non-printable characters to \\xHH format."""
16+
return ''.join(
17+
c if c.isprintable() or c in '\n\r\t' else f"\\x{ord(c):02x}"
18+
for c in text)
19+
20+
1421
def update(output_path, return_code, analyzer_info,
1522
analyzer_cmd, stdout, stderr):
1623

@@ -29,10 +36,10 @@ def update(output_path, return_code, analyzer_info,
2936

3037
data = {
3138
'analyzer_name': analyzer_info.name,
32-
'analyzer_cmd': analyzer_cmd,
39+
'analyzer_cmd': convert_to_printable(analyzer_cmd),
3340
'return_code': return_code,
34-
'stdout': stdout,
35-
'stderr': stderr
41+
'stdout': convert_to_printable(stdout),
42+
'stderr': convert_to_printable(stderr)
3643
}
3744

3845
parser.write(data, plist_err_path)

0 commit comments

Comments
 (0)