fix: web config tool including \r in prompt (#4969)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
This commit is contained in:
Justin 2022-10-26 01:07:20 +11:00 committed by GitHub
parent ed11f319fa
commit 1fe284122d
Failed to generate hash of commit
2 changed files with 3 additions and 2 deletions

View file

@ -1,5 +1,6 @@
"""functions to update rc files"""
import os
import re
import typing as tp
RENDERERS: tp.List[tp.Callable] = []
@ -39,7 +40,7 @@ def config_to_xonsh(
for func in RENDERERS:
lines.extend(func(config))
lines.append(suffix)
return "\n".join(lines)
return re.sub(r"\\r", "", "\n".join(lines))
def insert_into_xonshrc(

View file

@ -239,7 +239,7 @@ class PromptsPage(Routes):
def post(self, data: "cgi.FieldStorage"):
if data:
prompt = data.getvalue(self.var_name)
prompt = data.getvalue(self.var_name).replace("\r", "")
self.env[self.var_name] = prompt
self.update_rc(prompt=prompt)