Skip to content

quote the filename in the default editor hook - #15364

Open
sage-mode-hunter wants to merge 1 commit into
ipython:mainfrom
sage-mode-hunter:editor-hook-quote-filename
Open

quote the filename in the default editor hook#15364
sage-mode-hunter wants to merge 1 commit into
ipython:mainfrom
sage-mode-hunter:editor-hook-quote-filename

Conversation

@sage-mode-hunter

Copy link
Copy Markdown
Contributor

The default editor hook runs the editor through the shell without quoting the filename:

  • editor() in core/hooks.py builds the command with shell=True and interpolates the filename raw
  • %edit only wraps the path in quotes when it has a space, so a filename with ';', '$(...)' or backticks runs before the editor opens
  • the path is not always user-typed: %edit on an object resolves it from the object's source file via inspect.getabsfile

install_editor already shlex-quotes the filename inside the hook; this makes the default hook do the same and drops the now-redundant quoting in %edit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant