Skip to content

Fix 362#520

Open
sorinmarta wants to merge 2 commits into
masterfrom
fix/image-caption-xss
Open

Fix 362#520
sorinmarta wants to merge 2 commits into
masterfrom
fix/image-caption-xss

Conversation

@sorinmarta

@sorinmarta sorinmarta commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Prevents admin editor attribute breakout from malicious captions.
@sorinmarta sorinmarta added the run analysis Runs phpcs and phpunit label Jul 23, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@includes/fields/class-fieldtypes-image.php`:
- Line 88: Update the caption assignment near $caption so it uses null
coalescing rather than empty(), preserving the valid string "0" produced by
convert_input(). Continue defaulting to an empty string only when $value[1] is
null or unset.
- Around line 482-485: Update convert_input() to safely handle partial or
malformed image arrays by using null-coalescing defaults for offsets 0 and 1,
and ensure both image and caption values are scalar or safely cast before
passing them to absint() and sanitize_text_field(). Preserve the existing
empty-string outputs for missing or invalid values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 58cdf4b5-40cb-4579-aa92-3c4a566ef688

📥 Commits

Reviewing files that changed from the base of the PR and between 13d14cc and 7a3b2b6.

📒 Files selected for processing (1)
  • includes/fields/class-fieldtypes-image.php

Comment thread includes/fields/class-fieldtypes-image.php Outdated
Comment thread includes/fields/class-fieldtypes-image.php Outdated
Preserve caption "0" and safely handle partial or malformed arrays.
@sorinmarta sorinmarta changed the title Fix stored XSS in image field caption Fix 362 Jul 23, 2026
@Strategy11 Strategy11 deleted a comment from coderabbitai Bot Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run analysis Runs phpcs and phpunit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant