-
-
Notifications
You must be signed in to change notification settings - Fork 491
Commit 676eb2f
Escape special characters in formatter configuration for Windows
The sketch code formatter configuration is passed to the ClangFormat tool as a string representing a JSON object via a
command line argument.
Previously, the contents of this string were not given any special treatment to ensure compatibility with the command
interpreter used on Windows machines. That did not result in problems only because the configuration didn't contain
problematic combinations of characters. This good fortune will not persist through updates to the configuration, so the
command must be properly processed.
The Windows command interpreter does not use the POSIX style backslash escaping. For this reason, escaped quotes in the
argument are recognized as normal quotes, meaning that the string alternates between quoted and unquoted states at
random. When a character with special significance to the Windows command interpreter happens to occur outside a quoted
section, an error results.
The solution is to use the Windows command interpreter's caret escaping on these characters. Since such an escaping
system is not recognized by POSIX shells, this is only done when the application is running on a Windows machine.
References:
- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/echo#remarks
- https://en.wikipedia.org/wiki/Escape_character#Windows_Command_Prompt 1 parent ce273ad commit 676eb2f
1 file changed
+15
-1
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | + | ||
1 | 2 |
| |
2 | 3 |
| |
3 | 4 |
| |
| |||
123 | 124 |
| |
124 | 125 |
| |
125 | 126 |
| |
126 | - | ||
127 | + | ||
127 | 128 |
| |
128 | 129 |
| |
129 | 130 |
| |
131 | + | ||
132 | + | ||
133 | + | ||
134 | + | ||
135 | + | ||
136 | + | ||
137 | + | ||
138 | + | ||
139 | + | ||
140 | + | ||
141 | + | ||
142 | + | ||
143 | + | ||
130 | 144 |
| |
131 | 145 |
| |
132 | 146 |
| |
|
0 commit comments