Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lsp: Ensure filepaths are properly escaped
Backslashes in Windows filepaths can cause issues ```python >>> import re >>> VARIABLE = re.compile(r"\$\{(\w+)\}") >>> VARIABLE.sub('\\path\\to\\cache', '${defaultBuildDir}/doctrees') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.12/re/__init__.py", line 334, in _compile_template return _sre.template(pattern, _parser.parse_template(repl, pattern)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/re/_parser.py", line 1075, in parse_template raise s.error('bad escape %s' % this, len(this)) from None re.error: bad escape \p at position 0 ``` Calling `re.escape` on the replacement ensures that characters like backslashes are escaped correctly ```python >>> VARIABLE.sub(re.escape('\\path\\to\\cache'), '${defaultBuildDir}/doctrees') '\\path\\to\\cache/doctrees' >>> ```
- Loading branch information