Skip to content

fix(providers): treat unicode punctuation as image path terminators - #10106

Merged
DOsinga merged 5 commits into
aaif-goose:mainfrom
Osraka:osraka/broaden-image-path-separators
Jul 3, 2026
Merged

fix(providers): treat unicode punctuation as image path terminators#10106
DOsinga merged 5 commits into
aaif-goose:mainfrom
Osraka:osraka/broaden-image-path-separators

Conversation

@Osraka

@Osraka Osraka commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • factor the image-path trailing-character check into an explicit terminator helper
  • treat emoji and a narrow Unicode punctuation set as path terminators
  • add regression coverage for emoji, ellipsis, em dash, zero-width, combining mark, and file: cases

Fixes #9399.

Why

After the stricter path parsing changes, visually separated prompts like {path}.png🙂 or {path}.png… more text are treated as if the following Unicode character is part of the filename. That makes detect_image_path miss valid local image paths.

This keeps the broader rule conservative: : is still not a terminator, and zero-width / combining characters remain glued so they do not reintroduce the false-positive class guarded by the earlier parser hardening.

Verification

  • cargo fmt --check
  • cargo test -p goose-providers test_detect_image_path

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40bc73312e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

..='\u{201F}' | '\u{2026}' | '\u{2039}' | '\u{203A}'
)
|| ('\u{2600}'..='\u{27BF}').contains(&c)
|| ('\u{1F300}'..='\u{1FAFF}').contains(&c)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include flag emoji in terminator range

When a user appends a flag emoji immediately after an image path, e.g. /tmp/photo.png🇺🇸, the first scalar is a Regional Indicator Symbol (U+1F1E6..U+1F1FF), which is outside this range. detect_image_path therefore still treats the flag as part of the filename and returns None, so the newly added emoji-terminator behavior misses a common emoji class; include that range or use Unicode emoji properties if emoji suffixes are meant to terminate paths.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 87b633a by adding the Regional Indicator Symbol range (U+1F1E6..U+1F1FF) and covering a flag emoji suffix in the unicode separator regression test. Local verification: cargo fmt --check && cargo test -p goose-providers test_detect_image_path.

@DOsinga DOsinga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Clean, well-scoped fix for #9399, with the codex flag-emoji comment addressed. The regression test exercises real detection behavior. Thanks for a solid first contribution!

@Osraka

Osraka commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Thank you, I'm eagerly awaiting its merge with my major.

@DOsinga
DOsinga added this pull request to the merge queue Jul 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jul 1, 2026
@Abhijay007

Copy link
Copy Markdown
Collaborator

@Osraka can you please look into merge conflicts

@Osraka
Osraka force-pushed the osraka/broaden-image-path-separators branch from 87b633a to 22900a1 Compare July 1, 2026 21:14
@Osraka

Osraka commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflicts by rebasing the branch onto current main.

I kept the upstream clean_path / image_path_candidate changes and reapplied this PR’s Unicode path terminator handling on top of them. I also updated the new assertions to use .as_deref() with the current Option<Cow<str>> return type.

Local validation:

  • cargo fmt --all --check
  • cargo test -p goose-providers detect_image_path

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22900a1ffa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +150 to +152
|| ('\u{2600}'..='\u{27BF}').contains(&c)
|| ('\u{1F1E6}'..='\u{1F1FF}').contains(&c)
|| ('\u{1F300}'..='\u{1FAFF}').contains(&c)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include common emoji blocks as terminators

When a user appends a common emoji outside these hard-coded ranges, such as /tmp/photo.png⭐ (U+2B50) or /tmp/photo.png⌚ (U+231A), is_path_terminator returns false, so detect_image_path treats the emoji as part of the filename and misses the existing image. This is still reproducible with U+2B50 even after the regional-indicator fix; include the remaining emoji blocks or use a Unicode emoji property if emoji suffixes are meant to terminate paths.

Useful? React with 👍 / 👎.

@Osraka

Osraka commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest Codex review note in 0ac4248.

I added the common emoji blocks that cover U+231A / U+2B50-style suffixes and added regression assertions for and .

Local validation:

  • cargo fmt --all --check
  • cargo test -p goose-providers detect_image_path

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ac42487c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +147 to +148
'"' | '\'' | '\u{00AB}' | '\u{00BB}' | '\u{2013}'
..='\u{201F}' | '\u{2026}' | '\u{2039}' | '\u{203A}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Support Unicode quotes at the leading boundary

When a user wraps the path in smart quotes, e.g. “/tmp/photo.png”, detection still returns None: the trailing now passes this terminator check, but the slash is skipped because the leading-boundary check still accepts only whitespace and ASCII quotes. Since ASCII-quoted paths are supported and this change adds Unicode quote terminators, the matching opening Unicode quotes should be accepted as path boundaries too.

Useful? React with 👍 / 👎.

@Osraka

Osraka commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest Codex review note in 29c47af.

I added Unicode quote characters as valid leading path boundaries, matching the existing Unicode quote terminators. The regression coverage now includes smart double quotes and guillemets around paths.

Local validation:

  • cargo fmt --all --check
  • cargo test -p goose-providers detect_image_path

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e846c72912

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +159 to +163
|| ('\u{2300}'..='\u{23FF}').contains(&c)
|| ('\u{2600}'..='\u{27BF}').contains(&c)
|| ('\u{2B00}'..='\u{2BFF}').contains(&c)
|| ('\u{1F1E6}'..='\u{1F1FF}').contains(&c)
|| ('\u{1F300}'..='\u{1FAFF}').contains(&c)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recognize keycap emoji terminators

When a user appends a keycap emoji immediately after an existing image path, e.g. /tmp/photo.png1️⃣, the first scalar after .png is the ASCII digit 1, so it does not match any of these emoji ranges and detect_image_path treats the emoji sequence as part of the filename and returns None. After the added emoji ranges, this multi-scalar emoji case still remains outside the per-character predicate; handle keycap sequences (or use Unicode emoji segmentation/properties) before rejecting the suffix.

Useful? React with 👍 / 👎.

e3742526 added a commit to cephalopod-ai/gosling that referenced this pull request Jul 3, 2026
Port audited changes from aaif-goose/goose#10106.

Upstream commits: 859672814, 22900a1ff, 0ac42487c, 29c47afa5.

Local audit: upstream path crates/goose-provider-types/src/images.rs maps to gosling's crates/goose-providers/src/images.rs; production logic and tests applied cleanly after that path translation.

Gate: source bin/activate-hermit && cargo fmt && cargo test -p goose-providers images::tests::test_detect_image_path
@DOsinga
DOsinga added this pull request to the merge queue Jul 3, 2026
Merged via the queue into aaif-goose:main with commit a0aed81 Jul 3, 2026
23 checks passed
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.

feat(providers): broaden is_path_separator to cover emoji / Unicode punctuation

3 participants