[PR #14767] fix(cli): normalize quoted and encoded image paths #40697

Open
opened 2026-04-23 01:33:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14767
Author: @Petsku01
Created: 3/10/2026
Status: 🔄 Open

Base: mainHead: fix/cli-image-path-normalization


📝 Commits (1)

  • 6bf471b fix(cli): normalize quoted and encoded image paths

📊 Changes

3 files changed (+73 additions, -5 deletions)

View changed files

📝 cmd/interactive.go (+3 -0)
📝 cmd/interactive_test.go (+44 -0)
📝 x/imagegen/cli.go (+26 -5)

📄 Description

Fixes #10333

Summary

  • normalize CLI image file paths more robustly during extraction
  • decode %20 (URL-encoded spaces) in file paths
  • handle prompt cleanup for both single-quoted and double-quoted file paths
  • align normalization behavior between cmd interactive flow and x/imagegen CLI flow
  • add regression tests for quoted paths and %20-encoded paths

Why

Dragging image paths into terminal input can include escaping/quoting/encoding variants.
This change makes path extraction resilient to those variants so image attachments are detected reliably.

Changes

  • cmd/interactive.go

    • add %20 decoding in normalizeFilePath
    • remove \"path\" variants from prompt after successful extraction
  • x/imagegen/cli.go

    • add shared-style normalizeFilePath helper
    • replace ad-hoc normalization with helper
    • remove both 'path' and \"path\" variants from prompt after extraction
  • cmd/interactive_test.go

    • TestExtractFileDataRemovesDoubleQuotedFilepath
    • TestExtractFileDataDecodesPercent20Path

🔄 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/14767 **Author:** [@Petsku01](https://github.com/Petsku01) **Created:** 3/10/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/cli-image-path-normalization` --- ### 📝 Commits (1) - [`6bf471b`](https://github.com/ollama/ollama/commit/6bf471bdf12058276b1f2c8425c9eefe32b22f6e) fix(cli): normalize quoted and encoded image paths ### 📊 Changes **3 files changed** (+73 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `cmd/interactive.go` (+3 -0) 📝 `cmd/interactive_test.go` (+44 -0) 📝 `x/imagegen/cli.go` (+26 -5) </details> ### 📄 Description Fixes #10333 ## Summary - normalize CLI image file paths more robustly during extraction - decode `%20` (URL-encoded spaces) in file paths - handle prompt cleanup for both single-quoted and double-quoted file paths - align normalization behavior between `cmd` interactive flow and `x/imagegen` CLI flow - add regression tests for quoted paths and `%20`-encoded paths ## Why Dragging image paths into terminal input can include escaping/quoting/encoding variants. This change makes path extraction resilient to those variants so image attachments are detected reliably. ## Changes - `cmd/interactive.go` - add `%20` decoding in `normalizeFilePath` - remove `\"path\"` variants from prompt after successful extraction - `x/imagegen/cli.go` - add shared-style `normalizeFilePath` helper - replace ad-hoc normalization with helper - remove both `'path'` and `\"path\"` variants from prompt after extraction - `cmd/interactive_test.go` - `TestExtractFileDataRemovesDoubleQuotedFilepath` - `TestExtractFileDataDecodesPercent20Path` --- <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-23 01:33:11 -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#40697