Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lexborisov/Modest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorКирилл Жумарин <azq2@ya.ru>2018-06-02 11:54:26 +0300
committerGitHub <noreply@github.com>2018-06-02 11:54:26 +0300
commit307b9630e093a9713e6bbe7c5572c73ebf4088a9 (patch)
treed0254e399d56e2e0e13edc91ff8f8b33c46ba621
parentaca935f07cd062e716f1f76bdf1363e6330b04b4 (diff)
fix doctype serialization by spec
-rwxr-xr-xsource/myhtml/serialization.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/source/myhtml/serialization.c b/source/myhtml/serialization.c
index 3fc5563..5d62a9b 100755
--- a/source/myhtml/serialization.c
+++ b/source/myhtml/serialization.c
@@ -146,33 +146,48 @@ mystatus_t myhtml_serialization_node_callback(myhtml_tree_node_t* node, mycore_c
if(attr && attr->key.data && attr->key.length) {
if(callback(attr->key.data, attr->key.length, ptr))
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
-
+
attr = attr->next;
- if(attr && attr->value.length == 6) {
- if(mycore_strcasecmp(attr->value.data, "SYSTEM") == 0) {
- if(callback(" SYSTEM", 7, ptr))
+ if (attr) {
+ myhtml_tree_attr_t *system_id = NULL, *public_id = NULL;
+
+ if (attr->value.length == 6) {
+ if (mycore_strcasecmp(attr->value.data, "SYSTEM") == 0) {
+ system_id = attr->next;
+ } else if (mycore_strcasecmp(attr->value.data, "PUBLIC") == 0) {
+ public_id = attr->next;
+ system_id = public_id ? public_id->next : NULL;
+ }
+ }
+
+ if(public_id && public_id->value.length > 0) {
+ if(callback(" PUBLIC \"", 9, ptr))
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
- } else if(mycore_strcasecmp(attr->value.data, "PUBLIC") == 0) {
- if(callback(" PUBLIC", 7, ptr))
+
+ if(callback(public_id->value.data, public_id->value.length, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+
+ if(callback("\"", 1, ptr))
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
}
- attr = attr->next;
-
- while (attr) {
+ if(system_id && system_id->value.length > 0) {
+ if(!public_id || public_id->value.length == 0) {
+ if(callback(" SYSTEM", 7, ptr))
+ return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
+ }
+
if(callback(" \"", 2, ptr))
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
- if(attr->value.data && attr->value.length) {
- if(callback(attr->value.data, attr->value.length, ptr))
+ if(system_id->value.data && system_id->value.length) {
+ if(callback(system_id->value.data, system_id->value.length, ptr))
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
}
if(callback("\"", 1, ptr))
return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION;
-
- attr = attr->next;
}
}
}