Skip to content

Escaped bash special characters for bash command - #2033

Merged
iLLiCiTiT merged 3 commits into
developfrom
enhancement/YN-1008_handle_special_chars_in_filenames_linux
Sep 4, 2026
Merged

Escaped bash special characters for bash command#2033
iLLiCiTiT merged 3 commits into
developfrom
enhancement/YN-1008_handle_special_chars_in_filenames_linux

Conversation

@kalisp

@kalisp kalisp commented Sep 2, 2026

Copy link
Copy Markdown
Member

Changelog Description

This handles passing file paths (or any weird arguments) with special characters that are used in bash commands (as & for example).

Issue occurred in Webpublisher uploading file like video_v001_b&w.mp4, but would happen also in Tray Publisher (on Linux/Macs).

Additional info

This approach is based on sending whole command as a string and shell=False. It recommended me to not do that, pass it as list, without that flag, but I think we had our reasons why we had it this way.

It is a question, if this approach should be actually used as it might be too 'blanket-wide', as it would escape & or '|' if they should be used as real bash special characters. But if we were already escaping parentheses, it might not be a valid worry.

Testing notes:

  1. upload video_v001_b&w.mp4 via Weppublisher service (!) or Tray Publisher on Linux/Mac
  2. shouldnt fail in ExtractReview

Excapes '&' and similar characters in file names
@kalisp
kalisp requested review from 64qam, BigRoy and iLLiCiTiT September 2, 2026 09:37
@kalisp kalisp self-assigned this Sep 2, 2026
@kalisp kalisp added type: enhancement Improvement of existing functionality or minor addition sponsored This is directly sponsored by a client or community member labels Sep 2, 2026
@ynbot ynbot added the size/XS label Sep 2, 2026

@iLLiCiTiT iLLiCiTiT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test it but looks reasonable.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Context-free escaping corrupts quoted file paths and alters intentional shell syntax.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Attempts to support special characters in POSIX shell command arguments.

Changes:

  • Escapes common shell metacharacters on non-Windows systems.
  • Broadens handling beyond Bash and sh environment detection.
File summaries
File Description
client/ayon_core/lib/execute.py Rewrites shell command strings to escape metacharacters.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +122 to +126
.replace("&", "\\&")
.replace(";", "\\;")
.replace("|", "\\|")
.replace("$", "\\$")
.replace(">", "\\>")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kalisp is this something you can validate?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing it on uploading video_v001_b&w.mp4 via Webpublisher service (which is running on Linux). Tray publisher on Linux/MacOS would do the trick too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use shell=False if that's what you're asking for?

@ynbot ynbot moved this to Review In Progress in PR reviewing Sep 3, 2026
@github-project-automation github-project-automation Bot moved this from Review In Progress to Merge Requested in PR reviewing Sep 3, 2026
@ynbot ynbot moved this from Merge Requested to Review In Progress in PR reviewing Sep 3, 2026
@iLLiCiTiT
iLLiCiTiT merged commit 33fadf9 into develop Sep 4, 2026
2 checks passed
@iLLiCiTiT
iLLiCiTiT deleted the enhancement/YN-1008_handle_special_chars_in_filenames_linux branch September 4, 2026 08:08
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in PR reviewing Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants