Keep a whitespace character when removing xml tags

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2020-12-04 14:07:25 +01:00
parent a35f8903f7
commit 613f25848d

View File

@ -25,14 +25,22 @@ 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(*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++;
}
}
}
return i;
}