Skip to content

Commit 6224a68

Browse files
authored
fix doctype serialization by spec
Implement missing serialization of: - PUBLIC/SYSTEM - systemId -publicId
1 parent 2d8e6a3 commit 6224a68

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

source/myhtml/serialization.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,35 @@ mystatus_t myhtml_serialization_node_callback(myhtml_tree_node_t* node, mycore_c
146146
if(attr && attr->key.data && attr->key.length) {
147147
if(callback(attr->key.data, attr->key.length, ptr))
148148
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
149+
150+
attr = attr->next;
151+
152+
if(attr && attr->value.length == 6) {
153+
if(strcasecmp(attr->value.data, "SYSTEM") == 0) {
154+
if(callback(" SYSTEM", 7, ptr))
155+
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
156+
} else if(strcasecmp(attr->value.data, "PUBLIC") == 0) {
157+
if(callback(" PUBLIC", 7, ptr))
158+
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
159+
}
160+
161+
attr = attr->next;
162+
163+
while (attr) {
164+
if(callback(" \"", 2, ptr))
165+
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
166+
167+
if(attr->value.data && attr->value.length) {
168+
if(callback(attr->value.data, attr->value.length, ptr))
169+
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
170+
}
171+
172+
if(callback("\"", 1, ptr))
173+
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
174+
175+
attr = attr->next;
176+
}
177+
}
149178
}
150179
}
151180

0 commit comments

Comments
 (0)