From 613f25848d3c0b17d28f2ddd43d660947d1edc09 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Fri, 4 Dec 2020 14:07:25 +0100 Subject: [PATCH] Keep a whitespace character when removing xml tags Signed-off-by: Janos SUTO --- src/extract.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/extract.c b/src/extract.c index 9d391449..488faaf7 100644 --- a/src/extract.c +++ b/src/extract.c @@ -25,12 +25,20 @@ int remove_xml(char *src, char *dest, int destlen, int *html){ memset(dest, 0, destlen); for(; *src; src++){ - if(*src == '<'){ *html = 1; continue; } - if(*src == '>'){ *html = 0; continue; } - - if(*html == 0){ - if(i < destlen) *(dest+i) = *src; - i++; + if(*src == '<'){ + *html = 1; + } + else if(*src == '>'){ + *html = 0; + // make sure there's a whitespace between tag contents + if(i < destlen && i > 0 && !isspace(dest[i-1])) + dest[i++] = ' '; + } + else{ + if(*html == 0){ + if(i < destlen) *(dest+i) = *src; + i++; + } } }