From b9f5d62abc9c8a58628671b3e163ab03ba40d671 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Sat, 28 Mar 2026 10:00:02 +0000 Subject: [PATCH] Correctly handle IPv6 IPs in webhook URLs (#43911, #29664). Patch by Holger Just (user:hjust). git-svn-id: https://svn.redmine.org/redmine/trunk@24537 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/webhook_endpoint_validator.rb | 2 +- test/unit/lib/webhook_endpoint_validator_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/webhook_endpoint_validator.rb b/lib/webhook_endpoint_validator.rb index ba1c41220..b0ceb96bf 100644 --- a/lib/webhook_endpoint_validator.rb +++ b/lib/webhook_endpoint_validator.rb @@ -33,7 +33,7 @@ class WebhookEndpointValidator < ActiveModel::EachValidator return false if uri.nil? return false unless valid_scheme?(uri.scheme) - return false unless valid_host?(uri.host) + return false unless valid_host?(uri.hostname) return false unless valid_port?(uri.port) true diff --git a/test/unit/lib/webhook_endpoint_validator_test.rb b/test/unit/lib/webhook_endpoint_validator_test.rb index d5317f214..dd53b6c07 100644 --- a/test/unit/lib/webhook_endpoint_validator_test.rb +++ b/test/unit/lib/webhook_endpoint_validator_test.rb @@ -95,5 +95,13 @@ class WebhookEndpointValidatorTest < ActiveSupport::TestCase assert h.errors[:url].any? end end + + %w[ + [2001:0db8:85a3:0000:0000:8a2e:0370:7334] + 8.8.8.8 + ].each do |host| + h = TestModel.new "http://#{host}" + assert h.valid?, "URI host #{host} should be valid" + end end end