commit b5c3d48091fb2856d768223deb42d3674edcc7b2
parent ce1c1697a4d3a0e592b47ae65b4096d21d4cb90b
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 28 Jul 2015 21:25:57 +0200
use new uri parser
Diffstat:
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git 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
@@ -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));
+ }
}
}