From b5c3d48091fb2856d768223deb42d3674edcc7b2 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 28 Jul 2015 21:25:57 +0200 Subject: use new uri parser --- sfeed.c | 5 +++-- sfeed_web.c | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sfeed.c b/sfeed.c index dcc4ce5..e7b7757 100644 --- a/sfeed.c +++ b/sfeed.c @@ -345,7 +345,7 @@ string_print(String *s) static void printfields(void) { - char timebuf[64]; + char link[4096], timebuf[64]; time_t t; int r; @@ -362,7 +362,8 @@ printfields(void) string_print(&ctx.item.title); putchar(FieldSeparator); /* always print absolute urls */ - printlink(ctx.item.link.data, baseurl, stdout); + if (absuri(ctx.item.link.data, baseurl, link, sizeof(link)) != -1) + fputs(link, stdout); putchar(FieldSeparator); string_print(&ctx.item.content); putchar(FieldSeparator); diff --git a/sfeed_web.c b/sfeed_web.c index 9a96959..4e7a8d5 100644 --- a/sfeed_web.c +++ b/sfeed_web.c @@ -7,8 +7,8 @@ #include "util.h" #include "xml.h" -static unsigned int isbase = 0, islink = 0, isfeedlink = 0, found = 0; -static char feedlink[4096] = "", basehref[4096] = "", feedtype[256] = ""; +static unsigned int isbase, islink, isfeedlink, found; +static char abslink[4096], feedlink[4096], basehref[4096], feedtype[256]; static void printfeedtype(const char *s, FILE *fp) @@ -46,7 +46,8 @@ xmltagstartparsed(XMLParser *p, const char *tag, size_t taglen, int isshort) printfeedtype(feedtype, stdout); putchar(' '); } - printlink(feedlink, basehref, stdout); + if(absuri(feedlink, basehref, abslink, sizeof(abslink)) != -1) + fputs(abslink, stdout); putchar('\n'); found++; } @@ -74,8 +75,9 @@ xmlattr(XMLParser *p, const char *tag, size_t taglen, const char *name, isfeedlink = 1; strlcpy(feedtype, value, sizeof(feedtype)); } - } else if(!strncasecmp(name, "href", namelen)) + } else if(!strncasecmp(name, "href", namelen)) { strlcpy(feedlink, value, sizeof(feedlink)); + } } } -- cgit v1.2.3