From 36bc8f90dbb01a2f37d80b5c01172020506c5422 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 27 Sep 2024 16:52:06 -0700 Subject: [PATCH] fix: properly quote filenames with spaces and special characters using shlex.quote() --- aider/commands.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index b98179a0f..68317be9f 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -3,6 +3,7 @@ import re import subprocess import sys import tempfile +import shlex from collections import OrderedDict from pathlib import Path @@ -575,9 +576,7 @@ class Commands: self.io.print(diff) def quote_fname(self, fname): - if " " in fname and '"' not in fname: - fname = f'"{fname}"' - return fname + return shlex.quote(fname) def completions_raw_read_only(self, document, complete_event): # Get the text before the cursor and strip leading spaces