close
Skip to content

Ensure our IPv4-in-IPv6 address check works for PHP <8.3 - #952

Merged
dkotter merged 3 commits into
WordPress:developfrom
dkotter:fix/private-ip-check
Aug 18, 2026
Merged

dkotter merged 3 commits into
WordPress:developfrom
dkotter:fix/private-ip-check

Conversation

@dkotter

@dkotter dkotter commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What?

Add in a new embeds_ipv4_address method to check if an IPv6 address embeds an IPv4 address.

Why?

We recently added more robust URL checking before allowing an image to be downloaded and our IPv4-in-IPv6 address check works as expected on PHP 8.3+ but PHP versions lower than that weren't working without additional checks.

How?

  • Adds a new embeds_ipv4_address method that we run when checking an IP to ensure we support PHP 8.2 and lower the same as PHP 8.3+

Use of AI Tools

AI assistance: Yes
Tool(s): Cursor
Model(s): Opus 5
Used for: Diagnosing the failing unit tests, figuring out the reason why and suggesting a fix. Review and testing by me

Testing Instructions

Not really much to test here as this is meant to prevent private IP addresses from being used when someone directly calls the Alt Text Ability with a custom image URL, so hard to reproduce. If desired, can test that the Alt Text Generation experiment still works as expected

Changelog Entry

n/a - This is just a fix that a different PR missed

Open WordPress Playground Preview

…ds an IPv4 address. This isn't needed for PHP 8.3+ but we need to support lower versions
@dkotter dkotter added this to the 1.3.0 milestone Aug 18, 2026
@dkotter dkotter self-assigned this Aug 18, 2026
@dkotter
dkotter requested a review from a team August 18, 2026 18:24
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov

codecov Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.39%. Comparing base (131db3d) to head (c98daac).

Files with missing lines Patch % Lines
includes/Abilities/Image/Alt_Text_Generation.php 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #952   +/-   ##
==========================================
  Coverage      74.39%   74.39%           
- Complexity      3107     3110    +3     
==========================================
  Files            132      132           
  Lines          12160    12166    +6     
==========================================
+ Hits            9046     9051    +5     
- Misses          3114     3115    +1     
Flag Coverage Δ
unit 74.39% <85.71%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter
dkotter requested a review from jeffpaul August 18, 2026 19:02
@dkotter
dkotter merged commit 528d897 into WordPress:develop Aug 18, 2026
31 checks passed
@dkotter
dkotter deleted the fix/private-ip-check branch August 18, 2026 19:30
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.

2 participants