/usr/share/doc/ruby-rubymail-doc/html/classes/RMail/Header.src/M000098.html is in ruby-rubymail-doc 1.0.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>add_message_id (RMail::Header)</title>
<link rel=StyleSheet href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body bgcolor="white">
<pre><span class="cmt"># File lib/rmail/header.rb, line 771</span>
<span class="kw">def</span> add_message_id(fqdn = <span class="kw">nil</span>)
<span class="cmt"># If they don't supply a fqdn, we supply one for them.</span>
<span class="cmt">#</span>
<span class="cmt"># First grab the From: field and see if we can use a domain from</span>
<span class="cmt"># there. If so, use that domain name plus the hash of the From:</span>
<span class="cmt"># field's value (this guarantees that bob@example.com and</span>
<span class="cmt"># sally@example.com will never have clashes).</span>
<span class="cmt">#</span>
<span class="cmt"># If there is no From: field, grab the current host name and use</span>
<span class="cmt"># some randomness from Ruby's random number generator. Since</span>
<span class="cmt"># Ruby's random number generator is fairly good this will</span>
<span class="cmt"># suffice so long as it is seeded corretly.</span>
<span class="cmt">#</span>
<span class="cmt"># P.S. There is no portable way to get the fully qualified</span>
<span class="cmt"># domain name of the current host. Those truly interested in</span>
<span class="cmt"># generating "correct" message-ids should pass it in. We</span>
<span class="cmt"># generate a hopefully random and unique domain name.</span>
<span class="kw">unless</span> fqdn
<span class="kw">unless</span> fqdn = from.domains.first
require <span class="str">'socket'</span>
fqdn = sprintf(<span class="str">"%s.invalid"</span>, Socket.gethostname)
<span class="kw">end</span>
<span class="kw">else</span>
raise ArgumentError, <span class="str">"fqdn must have at least one dot"</span> <span class="kw">unless</span>
fqdn.index(<span class="str">'.'</span>)
<span class="kw">end</span>
<span class="cmt"># Hash the header we have so far.</span>
md5 = Digest::MD5.new
starting_digest = md5.digest
@fields.each { |f|
<span class="kw">if</span> f.raw
md5.update(f.raw)
<span class="kw">else</span>
md5.update(f.name) <span class="kw">if</span> f.name
md5.update(f.value) <span class="kw">if</span> f.value
<span class="kw">end</span>
}
<span class="kw">if</span> (digest = md5.digest) == starting_digest
digest = 0
<span class="kw">end</span>
set(<span class="str">'Message-Id'</span>, sprintf(<span class="str">"<%s.%s.%s.rubymail@%s>"</span>,
base36(Time.now.to_i),
base36(rand(MESSAGE_ID_MAXRAND)),
base36(digest),
fqdn))
<span class="kw">end</span></pre>
</body>
</html>
|