diff options
Diffstat (limited to 'lib/python')
-rwxr-xr-x | lib/python/qmk/cli/generate/config_h.py | 3 | ||||
-rw-r--r-- | lib/python/qmk/info.py | 2 | ||||
-rw-r--r-- | lib/python/qmk/tests/test_cli_commands.py | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index a26dcdf7d7..a2178bf1e9 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -117,9 +117,10 @@ def generate_config_items(kb_info_json, config_h_lines): config_h_lines.append(f'# define {key} {value}') config_h_lines.append(f'#endif // {key}') elif key_type == 'str': + escaped_str = config_value.replace('\\', '\\\\').replace('"', '\\"') config_h_lines.append('') config_h_lines.append(f'#ifndef {config_key}') - config_h_lines.append(f'# define {config_key} "{config_value}"') + config_h_lines.append(f'# define {config_key} "{escaped_str}"') config_h_lines.append(f'#endif // {config_key}') elif key_type == 'bcd_version': (major, minor, revision) = config_value.split('.') diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index c95b55916c..e0a46e7ed1 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -479,7 +479,7 @@ def _config_to_json(key_type, config_value): return int(config_value) elif key_type == 'str': - return config_value.strip('"') + return config_value.strip('"').replace('\\"', '"').replace('\\\\', '\\') elif key_type == 'bcd_version': major = int(config_value[2:4]) diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index fde8b079a3..185abb5f21 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -265,8 +265,8 @@ def test_generate_config_h(): check_returncode(result) assert '# define DEVICE_VER 0x0001' in result.stdout assert '# define DIODE_DIRECTION COL2ROW' in result.stdout - assert '# define MANUFACTURER none' in result.stdout - assert '# define PRODUCT pytest' in result.stdout + assert '# define MANUFACTURER "none"' in result.stdout + assert '# define PRODUCT "pytest"' in result.stdout assert '# define PRODUCT_ID 0x6465' in result.stdout assert '# define VENDOR_ID 0xFEED' in result.stdout assert '# define MATRIX_COLS 1' in result.stdout |