<commit_before># See #MX

# = Mail Exchange Record (MX)
# Defined in RFC 1035. Specifies the name and relative preference of mail 
# servers (mail exchangers in the DNS jargon) for the zone.
#
# Obtained from http://www.zytrax.com/books/dns/ch8/mx.html
#
class MX < Record
  
  validates_numericality_of :prio,
    :greater_than_or_equal_to => 0,
    :less_than_or_equal_to => 65535,
    :only_integer => true
  
  validates_presence_of :content
  
  # Only accept valid IPv4 addresses
  def validate_with_mx
    if content =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
      errors.add('content', 'Cannot be an IP address')
    end
    validate_without_mx
  end
  alias_method_chain :validate, :mx

  def supports_prio?
    true
  end
end<commit_msg>Don't allow spaces in the MX record content [#67]<commit_after># See #MX

# = Mail Exchange Record (MX)
# Defined in RFC 1035. Specifies the name and relative preference of mail 
# servers (mail exchangers in the DNS jargon) for the zone.
#
# Obtained from http://www.zytrax.com/books/dns/ch8/mx.html
#
class MX < Record
  
  validates_numericality_of :prio,
    :greater_than_or_equal_to => 0,
    :less_than_or_equal_to => 65535,
    :only_integer => true
  
  validates_presence_of :content
  validates_format_of :content,
    :allow_blank => true,
    :with => /\A\S+\Z/
  
  # Only accept valid IPv4 addresses
  def validate_with_mx
    if content =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
      errors.add('content', 'Cannot be an IP address')
    end
    validate_without_mx
  end
  alias_method_chain :validate, :mx

  def supports_prio?
    true
  end
end
{'fraction_non_alphanumeric': 0.1504938988959907, 'fraction_numerical': 0.05113306217315514, 'mean_word_length': 3.5797872340425534, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7413207', 'n_tokens_mistral': 726, 'n_tokens_neox': 684, 'n_words': 159}