diff --git a/src/ChangeLog b/src/ChangeLog
index ec409e10..96a30fdb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2001-11-16  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+	* headers.c (header_extract_number): Ignore trailing whitespace.
+
 2001-08-24  Ian Abbott  <abbotti@mev.co.uk>
 
 	* html-url.c (collect_tags_mapper): Fix bug converting links
diff --git a/src/headers.c b/src/headers.c
index 45ab9875..7f8693a3 100644
--- a/src/headers.c
+++ b/src/headers.c
@@ -149,6 +149,15 @@ header_extract_number (const char *header, void *closure)
 
   for (result = 0; ISDIGIT (*p); p++)
     result = 10 * result + (*p - '0');
+
+  /* Failure if no number present. */
+  if (p == header)
+    return 0;
+
+  /* Skip trailing whitespace. */
+  p += skip_lws (p);
+
+  /* Indicate failure if trailing garbage is present. */
   if (*p)
     return 0;