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,12 +25,20 @@ int remove_xml(char *src, char *dest, int destlen, int *html){
memset(dest, 0, destlen); memset(dest, 0, destlen);
for(; *src; src++){ for(; *src; src++){
if(*src == '<'){ *html = 1; continue; } if(*src == '<'){
if(*src == '>'){ *html = 0; continue; } *html = 1;
}
if(*html == 0){ else if(*src == '>'){
if(i < destlen) *(dest+i) = *src; *html = 0;
i++; // 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++;
}
} }
} }