Fix for nbsp in tag attribs
This commit is contained in:
parent
3dab626285
commit
fb09e38602
@ -4,7 +4,7 @@
|
||||
#include "www_tree.h"
|
||||
#include "bbs.h"
|
||||
|
||||
static char *www_tag_sanatize(char *data) {
|
||||
static char *www_tag_sanatize(char *data, int isdata) {
|
||||
stralloc str = EMPTY_STRALLOC;
|
||||
for (char *p = data; *p != '\0'; ++p) {
|
||||
switch (*p) {
|
||||
@ -521,6 +521,7 @@ static char *www_tag_sanatize(char *data) {
|
||||
stralloc_cats(&str, "▪");
|
||||
break;
|
||||
case ' ':
|
||||
if (isdata) {
|
||||
if (*(p+1) == ' ') {
|
||||
stralloc_cats(&str, " ");
|
||||
} else {
|
||||
@ -532,6 +533,9 @@ static char *www_tag_sanatize(char *data) {
|
||||
stralloc_append1(&str, ' ');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stralloc_append1(&str, ' ');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -555,7 +559,7 @@ struct www_tag *www_tag_new(char *tag, char *data) {
|
||||
new_tag->tag = NULL;
|
||||
|
||||
/* SANATIZE DATA HERE */
|
||||
new_tag->data = www_tag_sanatize(data);
|
||||
new_tag->data = www_tag_sanatize(data, 1);
|
||||
} else {
|
||||
new_tag->tag = strdup(tag);
|
||||
new_tag->data = NULL;
|
||||
@ -579,7 +583,7 @@ struct www_tag *www_tag_duplicate(struct www_tag *oldtag) {
|
||||
|
||||
void www_tag_add_attrib(struct www_tag *tag, char *attrib, char *value) {
|
||||
ptr_vector_append(&tag->attribs, strdup(attrib));
|
||||
ptr_vector_append(&tag->values, www_tag_sanatize(value));
|
||||
ptr_vector_append(&tag->values, www_tag_sanatize(value, 0));
|
||||
}
|
||||
|
||||
void www_tag_add_child(struct www_tag *tag, struct www_tag *child) {
|
||||
|
Reference in New Issue
Block a user