summaryrefslogtreecommitdiff
path: root/storage/connect/domdoc.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-03-02 17:58:18 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2013-03-02 17:58:18 +0100
commit5972b56a6d43aceb89e5242b6c323743eba9c71e (patch)
tree9cb05cd22e464d31e8d3d0d42f890b9d18f68c08 /storage/connect/domdoc.cpp
parent8c8fe2f3a62191d0d3e835242c08c23906478099 (diff)
downloadmariadb-git-5972b56a6d43aceb89e5242b6c323743eba9c71e.tar.gz
- Fix conversion bug for MS-DOM XML tables. The node content was written
and read as if the table DATA_CHARSET was ANSI instead of UTF-8. Warning are now provided when the read content of a node is truncated. modified: storage/connect/domdoc.cpp storage/connect/domdoc.h storage/connect/libdoc.cpp storage/connect/libdoc.h storage/connect/plgxml.h storage/connect/tabxml.cpp - Conditional compilation of pre_create depending on the MARIADB setting. modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h
Diffstat (limited to 'storage/connect/domdoc.cpp')
-rw-r--r--storage/connect/domdoc.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp
index 48aef29d6d8..95426be97bc 100644
--- a/storage/connect/domdoc.cpp
+++ b/storage/connect/domdoc.cpp
@@ -295,16 +295,41 @@ PXNODE DOMNODE::GetChild(PGLOBAL g)
/******************************************************************/
/* Return the content of a node and subnodes. */
/******************************************************************/
-char *DOMNODE::GetText(char *buf, int len)
+RCODE DOMNODE::GetContent(PGLOBAL g, char *buf, int len)
{
+ RCODE rc = RC_OK;
+
// Nodep can be null for a missing HTML table column
- if (Nodep)
- strncpy(buf, Nodep->text, len);
- else
+ if (Nodep) {
+ if (!WideCharToMultiByte(CP_UTF8, 0, Nodep->text, -1,
+ buf, len, NULL, NULL)) {
+ DWORD lsr = GetLastError();
+
+ switch (lsr) {
+ case 0:
+ case ERROR_INSUFFICIENT_BUFFER: // 122L
+ sprintf(g->Message, "Truncated %s content", GetName(g));
+ rc = RC_INFO;
+ break;
+ case ERROR_NO_UNICODE_TRANSLATION: // 1113L
+ sprintf(g->Message, "Invalid character(s) in %s content",
+ GetName(g));
+ rc = RC_INFO;
+ break;
+ default:
+ sprintf(g->Message, "System error getting %s content",
+ GetName(g));
+ rc = RC_FX;
+ break;
+ } // endswitch
+
+ } // endif
+
+ } else
*buf = '\0';
- return buf;
- } // end of GetText
+ return rc;
+ } // end of GetContent
/******************************************************************/
/* Set the text content of an attribute. */
@@ -319,8 +344,8 @@ bool DOMNODE::SetContent(PGLOBAL g, char *txtp, int len)
Len = len;
} // endif len
- if (!MultiByteToWideChar(CP_ACP, 0, txtp, strlen(txtp) + 1,
- Ws, Len + 1)) {
+ if (!MultiByteToWideChar(CP_UTF8, 0, txtp, strlen(txtp) + 1,
+ Ws, Len + 1)) {
sprintf(g->Message, MSG(WS_CONV_ERR), txtp);
return true;
} // endif