lib/spf/model.rb in spf-0.0.29 vs lib/spf/model.rb in spf-0.0.30
- old
+ new
@@ -927,10 +927,17 @@
@terms << mod
end
end
else
- raise SPF::JunkInRecordError.new("Junk encountered in record '#{@text}'", @text, @parse_text)
+ token_text = @parse_text.sub(/\s.*/, '')
+ hint = nil
+ if token_text =~ /#{SPF::Term::IPV4_ADDRESS_PATTERN}/x
+ hint = 'missing ip4: before IPv4 address?'
+ elsif token_text =~ /#{SPF::Term::IPV6_ADDRESS_PATTERN}/x
+ hint = 'missing ip6: before IPv6 address?'
+ end
+ raise SPF::JunkInRecordError.new("Junk encountered in record '#{@text}'", @text, @parse_text, hint)
end
@errors.concat(term.errors)
return term
end