{"thread":{"id":"25803","subject":"[PATCH] Make WebDAV XML parser namespace aware","startedAt":"2010-11-21T21:54:36Z","lastAt":"2010-11-21T21:54:36Z","messageCount":1,"participants":["Gabriel Corona"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"156295","messageId":"1290376476-24435-1-git-send-email-gabriel.corona@enst-bretagne.fr","threadId":"25803","inReplyTo":null,"subject":"[PATCH] Make WebDAV XML parser namespace aware","fromName":"Gabriel Corona","fromEmail":"gabriel.corona@enst-bretagne.fr","sentAt":"2010-11-21T21:54:36Z","receivedAt":"2010-11-21T21:54:36Z","isPatch":true,"sender":{"key":"gabriel.corona@enst-bretagne.fr","avatar":null},"body":"Previous implementation ignored the XML namespaces, considering only\nthe local name.\n\nSigned-off-by: Gabriel Corona <gabriel.corona@enst-bretagne.fr>\n---\n http-push.c |   45 ++++++++++++++++-----------------------------\n 1 files changed, 16 insertions(+), 29 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex c9bcd11..4ec3304 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -42,15 +42,15 @@ enum XML_Status {\n #define DAV_LOCK_OK (1u << 2)\n \n /* DAV XML properties */\n-#define DAV_CTX_LOCKENTRY \".multistatus.response.propstat.prop.supportedlock.lockentry\"\n-#define DAV_CTX_LOCKTYPE_WRITE \".multistatus.response.propstat.prop.supportedlock.lockentry.locktype.write\"\n-#define DAV_CTX_LOCKTYPE_EXCLUSIVE \".multistatus.response.propstat.prop.supportedlock.lockentry.lockscope.exclusive\"\n-#define DAV_ACTIVELOCK_OWNER \".prop.lockdiscovery.activelock.owner.href\"\n-#define DAV_ACTIVELOCK_TIMEOUT \".prop.lockdiscovery.activelock.timeout\"\n-#define DAV_ACTIVELOCK_TOKEN \".prop.lockdiscovery.activelock.locktoken.href\"\n-#define DAV_PROPFIND_RESP \".multistatus.response\"\n-#define DAV_PROPFIND_NAME \".multistatus.response.href\"\n-#define DAV_PROPFIND_COLLECTION \".multistatus.response.propstat.prop.resourcetype.collection\"\n+#define DAV_CTX_LOCKENTRY \"\\tDAV: multistatus\\tDAV: response\\tDAV: propstat\\tDAV: prop\\tDAV: supportedlock\\tDAV: lockentry\"\n+#define DAV_CTX_LOCKTYPE_WRITE \"\\tDAV: multistatus\\tDAV: response\\tDAV: propstat\\tDAV: prop\\tDAV: supportedlock\\tDAV: lockentry\\tDAV: locktype\\tDAV: write\"\n+#define DAV_CTX_LOCKTYPE_EXCLUSIVE \"\\tDAV: multistatus\\tDAV: response\\tDAV: propstat\\tDAV: prop\\tDAV: supportedlock\\tDAV: lockentry\\tDAV: lockscope\\tDAV: exclusive\"\n+#define DAV_ACTIVELOCK_OWNER \"\\tDAV: prop\\tDAV: lockdiscovery\\tDAV: activelock\\tDAV: owner\\tDAV: href\"\n+#define DAV_ACTIVELOCK_TIMEOUT \"\\tDAV: prop\\tDAV: lockdiscovery\\tDAV: activelock\\tDAV: timeout\"\n+#define DAV_ACTIVELOCK_TOKEN \"\\tDAV: prop\\tDAV: lockdiscovery\\tDAV: activelock\\tDAV: locktoken\\tDAV: href\"\n+#define DAV_PROPFIND_RESP \"\\tDAV: multistatus\\tDAV: response\"\n+#define DAV_PROPFIND_NAME \"\\tDAV: multistatus\\tDAV: response\\tDAV: href\"\n+#define DAV_PROPFIND_COLLECTION \"\\tDAV: multistatus\\tDAV: response\\tDAV: propstat\\tDAV: prop\\tDAV: resourcetype\\tDAV: collection\"\n \n /* DAV request body templates */\n #define PROPFIND_SUPPORTEDLOCK_REQUEST \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\" ?>\\n<D:propfind xmlns:D=\\\"DAV:\\\">\\n<D:prop xmlns:R=\\\"%s\\\">\\n<D:supportedlock/>\\n</D:prop>\\n</D:propfind>\"\n@@ -808,22 +808,16 @@ static void\n xml_start_tag(void *userData, const char *name, const char **atts)\n {\n \tstruct xml_ctx *ctx = (struct xml_ctx *)userData;\n-\tconst char *c = strchr(name, ':');\n \tint new_len;\n \n-\tif (c == NULL)\n-\t\tc = name;\n-\telse\n-\t\tc++;\n-\n-\tnew_len = strlen(ctx->name) + strlen(c) + 2;\n+\tnew_len = strlen(ctx->name) + strlen(name) + 2;\n \n \tif (new_len > ctx->len) {\n \t\tctx->name = xrealloc(ctx->name, new_len);\n \t\tctx->len = new_len;\n \t}\n-\tstrcat(ctx->name, \".\");\n-\tstrcat(ctx->name, c);\n+\tstrcat(ctx->name, \"\\t\");\n+\tstrcat(ctx->name, name);\n \n \tfree(ctx->cdata);\n \tctx->cdata = NULL;\n@@ -835,17 +829,10 @@ static void\n xml_end_tag(void *userData, const char *name)\n {\n \tstruct xml_ctx *ctx = (struct xml_ctx *)userData;\n-\tconst char *c = strchr(name, ':');\n \tchar *ep;\n \n \tctx->userFunc(ctx, 1);\n-\n-\tif (c == NULL)\n-\t\tc = name;\n-\telse\n-\t\tc++;\n-\n-\tep = ctx->name + strlen(ctx->name) - strlen(c) - 1;\n+\tep = ctx->name + strlen(ctx->name) - strlen(name) - 1;\n \t*ep = 0;\n }\n \n@@ -934,7 +921,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)\n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n \t\tif (results.curl_result == CURLE_OK) {\n-\t\t\tXML_Parser parser = XML_ParserCreate(NULL);\n+\t\t\tXML_Parser parser = XML_ParserCreateNS(NULL, ' ');\n \t\t\tenum XML_Status result;\n \t\t\tctx.name = xcalloc(10, 1);\n \t\t\tctx.len = 0;\n@@ -1177,7 +1164,7 @@ static void remote_ls(const char *path, int flags,\n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n \t\tif (results.curl_result == CURLE_OK) {\n-\t\t\tXML_Parser parser = XML_ParserCreate(NULL);\n+\t\t\tXML_Parser parser = XML_ParserCreateNS(NULL, ' ');\n \t\t\tenum XML_Status result;\n \t\t\tctx.name = xcalloc(10, 1);\n \t\t\tctx.len = 0;\n@@ -1260,7 +1247,7 @@ static int locking_available(void)\n \tif (start_active_slot(slot)) {\n \t\trun_active_slot(slot);\n \t\tif (results.curl_result == CURLE_OK) {\n-\t\t\tXML_Parser parser = XML_ParserCreate(NULL);\n+\t\t\tXML_Parser parser = XML_ParserCreateNS(NULL, ' ');\n \t\t\tenum XML_Status result;\n \t\t\tctx.name = xcalloc(10, 1);\n \t\t\tctx.len = 0;\n-- \n1.7.2.3\n"}]}