summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Schweinsberg <pazz0@0xfa.de>2019-06-10 15:47:46 +0000
committerHiltjo Posthuma <hiltjo@codemadness.org>2019-06-11 20:43:01 +0200
commit787473ebd7079cf6cb285216310b169ff0fd2f85 (patch)
tree97f6cfb4daab5fc4f42c0d0a5981c6a1ac4201c5
parentc18bb8bf4a78c62ebc032c1f30db38f78f550795 (diff)
Handle entities in attribute values.
-rw-r--r--sfeed.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sfeed.c b/sfeed.c
index fee47ce..a2e0cf3 100644
--- a/sfeed.c
+++ b/sfeed.c
@@ -109,6 +109,8 @@ static void xmlattrend(XMLParser *, const char *, size_t, const char *,
size_t);
static void xmlattrstart(XMLParser *, const char *, size_t, const char *,
size_t);
+static void xmlattrentity(XMLParser *, const char *, size_t, const char *,
+ size_t, const char *, size_t);
static void xmlcdata(XMLParser *, const char *, size_t);
static void xmldata(XMLParser *, const char *, size_t);
static void xmldataentity(XMLParser *, const char *, size_t);
@@ -681,6 +683,26 @@ xmlattrstart(XMLParser *p, const char *t, size_t tl, const char *n, size_t nl)
}
static void
+xmlattrentity(XMLParser *p, const char *t, size_t tl, const char *n, size_t nl,
+ const char *data, size_t datalen)
+{
+ char buf[16];
+ ssize_t len;
+
+ /* handles transforming inline XML to data */
+ if (ISINCONTENT(ctx)) {
+ if (ctx.contenttype == ContentTypeHTML)
+ xmldata(p, data, datalen);
+ return;
+ }
+
+ if ((len = xml_entitytostr(data, buf, sizeof(buf))) > 0)
+ xmlattr(p, t, tl, n, nl, buf, (size_t)len);
+ else
+ xmlattr(p, t, tl, n, nl, data, datalen);
+}
+
+static void
xmlcdata(XMLParser *p, const char *s, size_t len)
{
if (!ctx.field)
@@ -883,6 +905,7 @@ main(int argc, char *argv[])
parser.xmlattr = xmlattr;
parser.xmlattrend = xmlattrend;
parser.xmlattrstart = xmlattrstart;
+ parser.xmlattrentity = xmlattrentity;
parser.xmlcdata = xmlcdata;
parser.xmldata = xmldata;
parser.xmldataentity = xmldataentity;