When entering an IP range that is not considered valid, the error is being set on the wrong key, thus getting an error like this:
TypeError: Argument 1 passed to Drupal\Core\Form\FormState::setError() must be of the type array, null given, called in /app/web/modules/contrib/restrict_ip/src/Form/ConfigForm.php...

The reason is that the module tries to set the error in restrict_ip_address_list element instead of address_list element.

I'll include a patch for this now.

Comments

fjgarlin created an issue. See original summary.

fjgarlin’s picture

Status: Active » Needs review
StatusFileSize
new1.47 KB

Patch attached.

jasonawant’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch. It applies cleanly and works as expected. Not sure if tests need to be updated for this though.

bill_redman’s picture

Hi, I encountered this error when trying the module today. After reading this post, I applied the patch. While the original error is gone, I now get one telling me that the IP range I entered is not a valid IP address range. Since I know that the range is valid since I use it on other systems, would you have any suggestions? The range is entered like this example: 123.22.128.0-123.22.191.255

I'm using Version 8.x-1.3 of the module.

Thanks.

jasonawant’s picture

Hi Bill,

Looks like you've combined different IPs and their ranges. Instead of 123.22.128.0-123.22.191.255, it would be 123.22.128.0-123.22.128.255 and anything between this range and 123.22.191.0-123.22.191.255

Jason

fjgarlin’s picture

Yes, these range validation are currently open issues not really related to this issue in this case:
* Check range across all IP chunks
* Add range support for IPV6 addresses

bill_redman’s picture

Jason - Thanks for your reply. My range example does work in other applications I have, but that doesn't mean it will everywhere. I see your point. I'll try a different approach.

fjgarlin - Thanks for your reply. I will check out the issues you indicated.

Regards,
Bill

brockfanning’s picture

Priority: Normal » Major

I ran into this bug and this approach worked. I think this is a major priority - since the module appears to be broken if a new user is trying an IP range that this module does not support.

promo-il’s picture

D8.8, PHP:7.2 patch#2 OK

  • Anybody committed 55401b9 on 3.x
    Issue #3001939 by fjgarlin, jasonawant, Anybody: Error validating IP...
anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thank you all! Fixed in 3.x release (3.0.0-beta3) - Please test!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.