Skip to content

A platform for community discussion. Free, open, simple.

Fix "Host is invalid" error when TLD >10 chars (#7948)

Julien Madcb0e5f1e5a3
diff --git a/app/models/embeddable_host.rb b/app/models/embeddable_host.rb
index 545eeba5f20..71b44785a88 100644
--- a/app/models/embeddable_host.rb
+++ b/app/models/embeddable_host.rb
@@ -63,7 +63,7 @@ class EmbeddableHost < ActiveRecord::Base
end
def host_must_be_valid
- if host !~ /\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,10}(:[0-9]{1,5})?(\/.*)?\Z/i &&
+ if host !~ /\A[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,24}(:[0-9]{1,5})?(\/.*)?\Z/i &&
host !~ /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(:[0-9]{1,5})?(\/.*)?\Z/ &&
host !~ /\A([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.)?localhost(\:[0-9]{1,5})?(\/.*)?\Z/i
errors.add(:host, I18n.t('errors.messages.invalid'))