From 6224a68f8675d00cd9f0232741470e61f7c02b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=96=D1=83=D0=BC?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=BD?= Date: Sat, 2 Jun 2018 11:12:15 +0300 Subject: [PATCH] fix doctype serialization by spec Implement missing serialization of: - PUBLIC/SYSTEM - systemId -publicId --- source/myhtml/serialization.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/source/myhtml/serialization.c b/source/myhtml/serialization.c index adae7e6..e18667e 100755 --- a/source/myhtml/serialization.c +++ b/source/myhtml/serialization.c @@ -146,6 +146,35 @@ 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(strcasecmp(attr->value.data, "SYSTEM") == 0) { + if(callback(" SYSTEM", 7, ptr)) + return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; + } else if(strcasecmp(attr->value.data, "PUBLIC") == 0) { + if(callback(" PUBLIC", 7, ptr)) + return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; + } + + attr = attr->next; + + while (attr) { + 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)) + return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; + } + + if(callback("\"", 1, ptr)) + return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; + + attr = attr->next; + } + } } }