[PR #15137] Fix: image path not recognized correctly with escaped spaces #15047

Open
opened 2026-04-13 01:09:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15137
Author: @oemtime
Created: 3/30/2026
Status: 🔄 Open

Base: mainHead: fix/issue-10333


📝 Commits (1)

  • b349367 fix: image path not recognized correctly with escaped spaces

📊 Changes

2 files changed (+2 additions, -2 deletions)

View changed files

📝 cmd/interactive.go (+1 -1)
📝 x/imagegen/cli.go (+1 -1)

📄 Description

Problem

When dragging an image in the CLI, file paths with escaped spaces are not properly recognized.

Example:

/Users/ollama/Library/Mobile\ Documents/com~apple~CloudDocs/screenshots/CleanShot\ 2025-04-17\ at\ 21.26.40@2x.png

Solution

Changed the regex pattern in extractFileNames from non-greedy (+?) to greedy (+) matching to ensure paths with escaped spaces are fully captured.

The non-greedy quantifier could cause premature matching when encountering escaped spaces (\ ) in file paths, resulting in incomplete path extraction.

Changes

  • cmd/interactive.go: Changed [\S\\ ]+? to [\S\\ ]+
  • x/imagegen/cli.go: Same fix for consistency

Fixes #10333


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15137 **Author:** [@oemtime](https://github.com/oemtime) **Created:** 3/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/issue-10333` --- ### 📝 Commits (1) - [`b349367`](https://github.com/ollama/ollama/commit/b349367d6afae3d1846227e89669069dc827612d) fix: image path not recognized correctly with escaped spaces ### 📊 Changes **2 files changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `cmd/interactive.go` (+1 -1) 📝 `x/imagegen/cli.go` (+1 -1) </details> ### 📄 Description ## Problem When dragging an image in the CLI, file paths with escaped spaces are not properly recognized. Example: ``` /Users/ollama/Library/Mobile\ Documents/com~apple~CloudDocs/screenshots/CleanShot\ 2025-04-17\ at\ 21.26.40@2x.png ``` ## Solution Changed the regex pattern in `extractFileNames` from non-greedy (`+?`) to greedy (`+`) matching to ensure paths with escaped spaces are fully captured. The non-greedy quantifier could cause premature matching when encountering escaped spaces (`\ `) in file paths, resulting in incomplete path extraction. ## Changes - `cmd/interactive.go`: Changed `[\S\\ ]+?` to `[\S\\ ]+` - `x/imagegen/cli.go`: Same fix for consistency Fixes #10333 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 01:09:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#15047