Gnus development mailing list
 help / color / mirror / Atom feed
From: Reiner Steib <4.uce.03.r.s@nurfuerspam.de>
Subject: messsage-user-fqdn
Date: Thu, 20 Feb 2003 22:50:53 +0100	[thread overview]
Message-ID: <v9bs16d3k2.fsf@marauder.physik.uni-ulm.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]

Hi,

nowadays, many people don't a have properly configured system, so that
`system-name' often isn't useful for the generation of the domain name
of Message-Ids.  Additionally, many people have the own FQDN
(e.g. from their provider, like CIS-DFN) or the have their own domain.

People often ask how to set the FQDN[1].  They are often advised to
redefine `message-make-fqdn' or `message-make-message-id' (ugly hacks,
IMHO) or to set `mail-host-address':

,----
| (defun message-make-fqdn ()
|   "copy docstring from orig def"
|   "hotmail.com")
| (defun message-make-message-id ()
|   (concat
|    "<" (message-unique-id)"@some domain name You like>"))
`----

But there only very rough checks in `message.el' concerning the
validity of this string (does it contain a dot?
localhost.*?). Ref. [1] also is a nice example about invalid domain
parts: "@a.z«". :-(

I propose to add a variable `messsage-user-fqdn' *and* add a better
validity check for the domain part as well.

,----
| 2003-02-20  Reiner Steib  <Reiner.Steib@gmx.de>
| 
| 	* message.el (message-user-fqdn, message-valid-fqdn-regexp): New
| 	variables.
| 	(message-make-fqdn): Use it.  Improved validity check.
| 
| 2003-02-20  Reiner Steib  <Reiner.Steib@gmx.de>
| 
| 	* message.texi (News Headers): Update description of Message-ID.
`----

The new variable `message-valid-fqdn-regexp' is a duplication of
`gnus-button-valid-fqdn-regexp'.  But AFAIK, it's not allowed to
require `gnus-art' from `message.el', is it?  What about the other way
round?  Other possibilities?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: message.messsage-user-fqdn.patch --]
[-- Type: text/x-patch, Size: 5433 bytes --]

Index: lisp/ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/ChangeLog,v
retrieving revision 6.2020
diff -u -r6.2020 ChangeLog
--- lisp/ChangeLog	20 Feb 2003 02:39:08 -0000	6.2020
+++ lisp/ChangeLog	20 Feb 2003 21:52:47 -0000
@@ -1,3 +1,9 @@
+2003-02-20  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* message.el (message-user-fqdn, message-valid-fqdn-regexp): New
+	variables.
+	(message-make-fqdn): Use it.  Improved validity check.
+
 2003-02-20  Jesper Harder  <harder@ifa.au.dk>
 
 	* gnus-sum.el (gnus-simplify-subject-fully, gnus-subject-equal)
Index: lisp/message.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/message.el,v
retrieving revision 6.301
diff -u -r6.301 message.el
--- lisp/message.el	20 Feb 2003 00:39:05 -0000	6.301
+++ lisp/message.el	20 Feb 2003 21:52:47 -0000
@@ -1273,6 +1273,12 @@
   :group 'message-headers
   :type 'boolean)
 
+(defcustom message-user-fqdn nil
+  "*Domain part of Messsage-Ids."
+  :group 'message-headers
+  :link '(custom-manual "(message)News Headers")
+  :type 'string)
+
 ;;; Internal variables.
 
 (defvar message-sending-message "Sending...")
@@ -1381,6 +1387,19 @@
 (defvar message-bogus-system-names "^localhost\\."
   "The regexp of bogus system names.")
 
+(defcustom message-valid-fqdn-regexp
+  (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
+	  ;; valid TLDs:
+	  "\\([a-z][a-z]" ;; two letter country TDLs
+	  "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
+	  "\\|aero\\|coop\\|info\\|name\\|museum"
+	  "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
+	  "\\)")
+  "Regular expression that matches a valid FQDN."
+  ;; see also: gnus-button-valid-fqdn-regexp
+  :group 'message-headers
+  :type 'regexp)
+
 (eval-and-compile
   (autoload 'message-setup-toolbar "messagexmas")
   (autoload 'mh-new-draft-name "mh-comp")
@@ -4483,23 +4502,34 @@
 
 (defun message-make-fqdn ()
   "Return user's fully qualified domain name."
-  (let ((system-name (system-name))
-	(user-mail (message-user-mail-address)))
+  (let* ((system-name (system-name))
+	 (user-mail (message-user-mail-address))
+	 (user-domain
+	  (if (string-match "@\\(.*\\)\\'" user-mail)
+	      (match-string 1 user-mail))))
     (cond
-     ((and (string-match "[^.]\\.[^.]" system-name)
+     ((and message-user-fqdn
+	   (stringp message-user-fqdn)
+	   (string-match message-valid-fqdn-regexp message-user-fqdn)
+	   (not (string-match message-bogus-system-names message-user-fqdn)))
+      message-user-fqdn)
+     ;; `message-user-fqdn' seems to be valid
+     ((and (string-match message-valid-fqdn-regexp system-name)
 	   (not (string-match message-bogus-system-names system-name)))
       ;; `system-name' returned the right result.
       system-name)
      ;; Try `mail-host-address'.
      ((and (boundp 'mail-host-address)
 	   (stringp mail-host-address)
-	   (string-match "\\." mail-host-address))
+	   (string-match message-valid-fqdn-regexp mail-host-address)
+	   (not (string-match message-bogus-system-names mail-host-address)))
       mail-host-address)
      ;; We try `user-mail-address' as a backup.
-     ((and user-mail
-	   (string-match "\\." user-mail)
-	   (string-match "@\\(.*\\)\\'" user-mail))
-      (match-string 1 user-mail))
+     ((and user-domain
+	   (stringp user-domain)
+	   (string-match message-valid-fqdn-regexp user-domain)
+	   (not (string-match message-bogus-system-names user-domain)))
+      user-domain)
      ;; Default to this bogus thing.
      (t
       (concat system-name ".i-did-not-set--mail-host-address--so-tickle-me")))))
Index: texi/ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/gnus/texi/ChangeLog,v
retrieving revision 6.457
diff -u -r6.457 ChangeLog
--- texi/ChangeLog	18 Feb 2003 20:32:24 -0000	6.457
+++ texi/ChangeLog	20 Feb 2003 21:52:47 -0000
@@ -1,3 +1,7 @@
+2003-02-20  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* message.texi (News Headers): Update description of Message-ID.
+
 2003-02-18  Reiner Steib  <Reiner.Steib@gmx.de>
 
 	* gnus.texi (Article Washing): Mention `g'.
Index: texi/message.texi
===================================================================
RCS file: /usr/local/cvsroot/gnus/texi/message.texi,v
retrieving revision 6.66
diff -u -r6.66 message.texi
--- texi/message.texi	5 Feb 2003 10:10:19 -0000	6.66
+++ texi/message.texi	20 Feb 2003 21:52:47 -0000
@@ -1466,14 +1466,18 @@
 
 @item Message-ID
 @cindex Message-ID
+@vindex message-user-fqdn
 @vindex mail-host-address
+@vindex user-mail-address
 @findex system-name
 @cindex Sun
+@cindex i-did-not-set--mail-host-address--so-tickle-me
 This required header will be generated by Message.  A unique ID will be
-created based on the date, time, user name and system name.  Message
-will use @code{system-name} to determine the name of the system.  If
-this isn't a fully qualified domain name (FQDN), Message will use
-@code{mail-host-address} as the FQDN of the machine.
+created based on the date, time, user name and system name.  For the
+domain part, message will look (in this order) at
+@code{message-user-fqdn}, @code{system-name}, @code{mail-host-address}
+and @code{message-user-mail-address} (i.e. @code{user-mail-address})
+until a probably valid fully qualified domain name (FQDN) was found.
 
 @item User-Agent
 @cindex User-Agent

[-- Attachment #3: Type: text/plain, Size: 152 bytes --]


Bye, Reiner.

[1] E.g. <news:86wujvvxpu.fsf@a.z>
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/

             reply	other threads:[~2003-02-20 21:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-20 21:50 Reiner Steib [this message]
2003-02-21 15:40 ` messsage-user-fqdn Kai Großjohann
2003-02-22 22:17 ` messsage-user-fqdn Lars Magne Ingebrigtsen
2003-02-23  6:32   ` messsage-user-fqdn Peter Wu
2003-02-23 10:29     ` messsage-user-fqdn Kai Großjohann
2003-02-23 11:31       ` messsage-user-fqdn Lars Magne Ingebrigtsen
2003-02-23 13:25         ` messsage-user-fqdn Kai Großjohann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=v9bs16d3k2.fsf@marauder.physik.uni-ulm.de \
    --to=4.uce.03.r.s@nurfuerspam.de \
    --cc=reiner.steib@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).