Page MenuHomePhabricator

ContributionsRangeTrait fails to parse CIDR using "X.X.X.X - Y.Y.Y.Y" format
Closed, ResolvedPublicBUG REPORT

Description

Summary

The ContributionsRangeTrait fails to parse a CIDR if it is in the format of X.X.X.X - Y.Y.Y.Y

Steps to replicate the issue

  1. Open https://en.wikipedia.org/w/index.php?oldid=323185528&title=Wikipedia:Abuse_reports/79.0.0.0_-_79.63.255.255 (or similar page where the page target is considered an IP range using the format X.X.X.X - Y.Y.Y.Y)

What happens?:
A logstash log appears with a PHP warning of Undefined array key 1

What should have happened instead?:
No logstash log should have been created

Event Timeline

Change #1226877 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/core@master] Consider IP range with dash as invalid in ContributionsRangeTrait

https://gerrit.wikimedia.org/r/1226877

Change #1226894 had a related patch set uploaded (by Aarohisharma3; author: Aarohisharma3):

[mediawiki/core@master] Fix parsing of dash-separated IP ranges in contributions

https://gerrit.wikimedia.org/r/1226894

I've submitted the patch : https://phabricator.wikimedia.org/T414592

Changes:

  • ContributionsRangeTrait: Added detection for dash-separated ranges before CIDR parsing, with safe splitting, whitespace trimming, and validation of both IP addresses
  • HTMLUserTextField: Added dash-separated range handling and count validation before array destructuring to prevent undefined index warnings
  • Both files now validate array count before accessing elements

The fix ensures that:

  • Dash-separated IP ranges are properly detected and handled
  • CIDR notation continues to work as expected
  • No undefined array key warnings are generated
  • Both IPv4 and IPv6 ranges are supported

I've submitted the patch : https://phabricator.wikimedia.org/T414592

Changes:

  • ContributionsRangeTrait: Added detection for dash-separated ranges before CIDR parsing, with safe splitting, whitespace trimming, and validation of both IP addresses
  • HTMLUserTextField: Added dash-separated range handling and count validation before array destructuring to prevent undefined index warnings
  • Both files now validate array count before accessing elements

The fix ensures that:

  • Dash-separated IP ranges are properly detected and handled
  • CIDR notation continues to work as expected
  • No undefined array key warnings are generated
  • Both IPv4 and IPv6 ranges are supported

Hi. I already have a patch I made for this task that I've discussed. I don't think we need changes to HTMLUserTextField as this does not currently affect Special:Contributions pages

Okay sure, makes sense
Thanks for the clarification!

Change #1226877 merged by jenkins-bot:

[mediawiki/core@master] Consider IP range with dash as invalid in ContributionsRangeTrait

https://gerrit.wikimedia.org/r/1226877

Dreamy_Jazz closed this task as Resolved.EditedJan 20 2026, 9:48 AM

The original bug described in this ticket is fixed on testwiki. A wider change in the other patch by Aarohisharma3 is probably best handled in a different ticket where the wider implications of modifying HTMLUserTextField can be considered

cc @Aarohisharma3 to create a new ticket if you still want to work on your patch

Thanks for closing this! Confirmed that the original issue is resolved.

I’ll create a new task to discuss the wider behaviour changes around handling dash-separated IP ranges in HTMLUserTextField and Contributions parsing, as suggested.

Change #1226894 abandoned by Aarohisharma3:

[mediawiki/core@master] Fix parsing of dash-separated IP ranges in contributions

https://gerrit.wikimedia.org/r/1226894