commit 4959de9c170b3d2d8dee622d50d0fae70ec5b463
parent 7a31e4fcdca0f2f82e9fea143dc157607a811ccf
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 8 Apr 2014 15:24:16 +0200
sfeed: fix entity conversion
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sfeed.c b/sfeed.c
@@ -151,6 +151,7 @@ namedentitytostr(const char *e, char *buffer, size_t bufsiz) {
{ NULL, NULL }
};
size_t i;
+
if(*e != '&' || bufsiz < 2) /* doesn't start with & */
return 0;
for(i = 0; entities[i][0]; i++) {
@@ -167,10 +168,10 @@ namedentitytostr(const char *e, char *buffer, size_t bufsiz) {
static int
entitytostr(const char *e, char *buffer, size_t bufsiz) {
unsigned long l = 0, cp = 0;
+
if(*e != '&' || bufsiz < 5) /* doesnt start with & */
return 0;
- e++;
- if(*e == '#') {
+ if(*(e+1) == '#') {
e++;
if(*e == 'x') {
e++;
@@ -582,7 +583,7 @@ xml_handler_data_entity(XMLParser *p, const char *data, size_t datalen) {
char buffer[16];
size_t len;
- /* TODO: for content HTML data entities, convert & to &? */
+ /* TODO: for content HTML data entities, convert & to & ? */
if((len = entitytostr(data, buffer, sizeof(buffer))))
xml_handler_data(p, buffer, len);
else