Commit cadca24
authored
msvs.py: Use floor division when escaping command-line arguments (#338)
Fixes nodejs/node-gyp#3296
* nodejs/node-gyp#3296
% `python3.14`
```
>>> import re
>>> s = "TEST_STRING=\\\"TEST\\\""
>>> quote_replacer_regex2 = re.compile(r'(\\+)"')
...
...
... def _EscapeCommandLineArgumentForMSBuild(s):
... """Escapes a Windows command-line argument for use by MSBuild."""
...
... def _Replace(match):
... return (len(match.group(1)) / 2 * 4) * "\\" + '\\"'
...
... # Escape all quotes so that they are interpreted literally.
... s = quote_replacer_regex2.sub(_Replace, s)
... return s
...
>>> _EscapeCommandLineArgumentForMSBuild(s)
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
_EscapeCommandLineArgumentForMSBuild(s)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File "<python-input-1>", line 11, in _EscapeCommandLineArgumentForMSBuild
s = quote_replacer_regex2.sub(_Replace, s)
File "<python-input-1>", line 8, in _Replace
return (len(match.group(1)) / 2 * 4) * "\\" + '\\"'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
TypeError: can't multiply sequence by non-int of type 'float'
>>> Modify _Replace() to use floor division...
>>> _EscapeCommandLineArgumentForMSBuild(s)
'TEST_STRING=\\"TEST\\"'1 parent 147fa1a commit cadca24
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
857 | 857 | | |
858 | 858 | | |
859 | 859 | | |
860 | | - | |
| 860 | + | |
861 | 861 | | |
862 | 862 | | |
863 | 863 | | |
| |||
0 commit comments