Article View: news.software.readers
Article #42935[slrn] PATCH: fixes for extract_article_header()
From: Lloyd Zusman
Date: Sun, 30 Aug 1998 00:00
Date: Sun, 30 Aug 1998 00:00
147 lines
6355 bytes
6355 bytes
I have a patch which (I hope!) fixes a couple bugs in that show up in
the `extract_article_header()' routine in Slrn. This routine is
actually a front end to `slrn_extract_header' in `art.c' in the Slrn
source, and this is where this patch gets applied.
Note that this patch is only valid for version 0.9.5.2 of Slrn.
One of the bugs that this patch fixes is that it will return the
"Lines:" value, even if it is applied to a header for a non-selected
article (other headers, such as "From:", "Subject:", etc. already work
properly within `extract_article_header' for non-selected articles).
This patch also does the equivalent of an `strtrim()' on the results
that it returns for all possible headers [NOTE: do we really want this
behavior for *all* headers?]
Another bug also gets fixed in this patch. In the case where
`extract_article_header()' gets applied to the currently-selected
article (and *only* in this case), it's possible that incorrect
results could be returned. For example, assume that the following
header appears in the currently-selected article ...
Subject: Foo bar
In this case, the result of `extract_article_header("Subj")' would be
ect: Foo bar
At least this appears to be the way that 0.9.5.2 works, given the way
the C code is written. I have also fixed this in my patch.
I hope that some of you will test and evaluate this patch, to make
sure that I haven't introduced some new errors. Everything looks good
so far in my own testing, but one never knows ...
Lloyd Zusman
ljz@asfast.com
--------------------------- patch begins here ---------------------------
*** art.c.orig Sun Aug 30 18:58:31 1998
--- art.c Sun Aug 30 19:39:52 1998
***************
*** 868,873 ****
--- 868,875 ----
char *slrn_extract_header (char *hdr, unsigned int len) /*{{{*/
{
Slrn_Article_Line_Type *l;
+ char *result = NULL;
+ int found;
if (Slrn_Current_Header == NULL)
return NULL;
***************
*** 878,895 ****
if (Slrn_Current_Header != Header_Showing)
{
if (0 == slrn_case_strncmp ((unsigned char *)"From: ", (unsigned char *)hdr, len))
! return Slrn_Current_Header->from;
! if (0 == slrn_case_strncmp ((unsigned char *)"Subject: ", (unsigned char *)hdr, len))
! return Slrn_Current_Header->subject;
! if (0 == slrn_case_strncmp ((unsigned char *)"Message-Id: ", (unsigned char *)hdr, len))
! return Slrn_Current_Header->msgid;
! if (0 == slrn_case_strncmp ((unsigned char *)"Date: ", (unsigned char *)hdr, len))
! return Slrn_Current_Header->date;
! if (0 == slrn_case_strncmp ((unsigned char *)"References: ", (unsigned char *)hdr, len))
! return Slrn_Current_Header->refs;
! if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ", (unsigned char *)hdr, len))
! return Slrn_Current_Header->from;
! return NULL;
}
l = Slrn_Article_Lines;
--- 880,907 ----
if (Slrn_Current_Header != Header_Showing)
{
if (0 == slrn_case_strncmp ((unsigned char *)"From: ", (unsigned char *)hdr, len))
! result = Slrn_Current_Header->from;
! else if (0 == slrn_case_strncmp ((unsigned char *)"Subject: ", (unsigned char *)hdr, len))
! result = Slrn_Current_Header->subject;
! else if (0 == slrn_case_strncmp ((unsigned char *)"Message-Id: ", (unsigned char *)hdr, len))
! result = Slrn_Current_Header->msgid;
! else if (0 == slrn_case_strncmp ((unsigned char *)"Date: ", (unsigned char *)hdr, len))
! result = Slrn_Current_Header->date;
! else if (0 == slrn_case_strncmp ((unsigned char *)"References: ", (unsigned char *)hdr, len))
! result = Slrn_Current_Header->refs;
! else if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ", (unsigned char *)hdr, len))
! result = Slrn_Current_Header->from;
! else if (0 == slrn_case_strncmp ((unsigned char *)"Lines: ", (unsigned char *)hdr, len))
! {
! static char headerLines[16];
! sprintf(headerLines, "%d", Slrn_Current_Header->lines);
! return headerLines;
! }
! if (NULL == result)
! return NULL;
!
! slrn_trim_string(result);
! return slrn_skip_whitespace(result);
}
l = Slrn_Article_Lines;
***************
*** 903,909 ****
if ((l->next != NULL) && (l->next->flags & WRAPPED_LINE))
unwrap_line (l->next);
! return l->buf + len;
}
l = l->next;
}
--- 915,948 ----
if ((l->next != NULL) && (l->next->flags & WRAPPED_LINE))
unwrap_line (l->next);
! /* Someone might have supplied a partial header, such as
! * "Subj". Therefore, we cannot assume that the end of the
! * supplied header string is the beginning of the data we
! * wish to return. We need to search for a colon and
! * return the first non-whitespace character which follows it.
! */
! found = 0;
! for (result = l->buf; '\0' != *result; result++)
! {
! if (' ' == *result || '\t' == *result)
! {
! /* ERROR! ... white space before colon.
! * Treat this as a non-match.
! */
! break;
! }
! else if (':' == *result)
! {
! result++;
! found = 1;
! break;
! }
! }
! if (!found)
! continue;
!
! slrn_trim_string(result);
! return slrn_skip_whitespace(result);
}
l = l->next;
}
Technical Details
Message-ID:
<lthfyunhe0.fsf_-_@asfast.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<slrn6uha35.l0.ljz@sunspot.tiac.net> <slrn6uj1m0.ff1.bluemoon@ux6.cso.uiuc.edu> <lt1zpypadr.fsf@asfast.com> <slrn6ujg18.89l.bluemoon@ux6.cso.uiuc.edu> <ltlno6nk3g.fsf@asfast.com>Show Full Headers
Complete Article Headers
Message-ID: <lthfyunhe0.fsf_-_@asfast.com> Subject: [slrn] PATCH: fixes for extract_article_header() Date: Sun, 30 Aug 1998 00:00:00 +0000 From: Lloyd Zusman <ljz@asfast.com> References: <slrn6uha35.l0.ljz@sunspot.tiac.net> <slrn6uj1m0.ff1.bluemoon@ux6.cso.uiuc.edu> <lt1zpypadr.fsf@asfast.com> <slrn6ujg18.89l.bluemoon@ux6.cso.uiuc.edu> <ltlno6nk3g.fsf@asfast.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 386277652 X-Complaints-To: newsabuse@supernews.com X-Trace: 904521989 NHG18.M.GE264CCFD usenet44.supernews.com Organization: http://www.supernews.com, The World's Usenet: Discussions Start Here Newsgroups: news.software.readers