Skip to content

Commit dec35ec

Browse files
committed
Fix Windows path escaping in dotenv fixtures
Escape backslashes when writing Windows paths to double-quoted .env values. The parse_dotenv function interprets \r, \t, etc. as escape sequences, so paths like C:\Users\runneradmin become corrupted when unescaped.
1 parent 6e23849 commit dec35ec

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎crates/socket-patch-cli/tests/in_process_python_envs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ async fn pipenv_dotenv_settings_pick_the_scanned_venv() {
689689
project.join(".env"),
690690
format!(
691691
"export WORKON_HOME=\"{}\"\nPIPENV_CUSTOM_VENV_NAME=proj-env # named\n",
692-
workon.display()
692+
workon.display().to_string().replace('\\', "\\\\")
693693
),
694694
)
695695
.unwrap();

‎crates/socket-patch-core/src/crawlers/python_crawler.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3545,9 +3545,10 @@ mod tests {
35453545
"HOME",
35463546
tmp.path().join("home").to_string_lossy().into_owned(),
35473547
)]);
3548+
let base_escaped = base.replace('\\', "\\\\");
35483549
for dotenv in [
35493550
format!("WORKON_HOME={base}/elsewhere\n"),
3550-
format!("# venvs\nexport WORKON_HOME=\"{base}/elsewhere\" # here\n"),
3551+
format!("# venvs\nexport WORKON_HOME=\"{base_escaped}/elsewhere\" # here\n"),
35513552
format!("WORKON_HOME='{base}/elsewhere'\n"),
35523553
format!("BASE={base}\nWORKON_HOME=${{BASE}}/elsewhere # comment\n"),
35533554
] {

0 commit comments

Comments
 (0)