1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- Fix the elimination of control characters from node content

- Take care of XML special chars (<>& etc.)
- Remove Encode, Decode

modified:
  storage/connect/libdoc.cpp
  storage/connect/libdoc.h

- Neither libmysql.lib nor mysqlclient.lib needed for MYSQL table type

modified:
  storage/connect/CMakeLists.txt
This commit is contained in:
Olivier Bertrand
2013-02-20 18:49:18 +01:00
parent 26bf803c04
commit b63eb1d8b4
3 changed files with 19 additions and 23 deletions

View File

@@ -155,10 +155,6 @@ OPTION(CONNECT_WITH_MYSQL
IF(CONNECT_WITH_MYSQL) IF(CONNECT_WITH_MYSQL)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} myconn.cpp tabmysql.cpp) SET(CONNECT_SOURCES ${CONNECT_SOURCES} myconn.cpp tabmysql.cpp)
# For static linking
#SET(MYSQL_LIBRARY mysqlclient)
# For dynamic linking
SET(MYSQL_LIBRARY libmysql)
add_definitions(-DMYSQL_SUPPORT) add_definitions(-DMYSQL_SUPPORT)
IF(NOT UNIX) IF(NOT UNIX)
# #
@@ -238,4 +234,4 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
STORAGE_ENGINE STORAGE_ENGINE
MODULE_OUTPUT_NAME "ha_connect" MODULE_OUTPUT_NAME "ha_connect"
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
${MYSQL_LIBRARY} ${ODBC_LIBRARY} ${IPHLPAPI_LIBRARY}) ${ODBC_LIBRARY} ${IPHLPAPI_LIBRARY})

View File

@@ -335,6 +335,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp)
return nl; return nl;
} // end of GetNodeList } // end of GetNodeList
#if 0 // Not used anymore
/******************************************************************/ /******************************************************************/
/* CheckDocument: check if the document is ok to dump. */ /* CheckDocument: check if the document is ok to dump. */
/* Currently this does the dumping of the document. */ /* Currently this does the dumping of the document. */
@@ -411,6 +412,7 @@ xmlChar *LIBXMLDOC::Encode(PGLOBAL g, char *txt)
buf[len]= '\0'; buf[len]= '\0';
return BAD_CAST buf; return BAD_CAST buf;
} // end of Encode } // end of Encode
#endif // 0
/* ---------------------- class XML2NODE ------------------------ */ /* ---------------------- class XML2NODE ------------------------ */
@@ -467,15 +469,14 @@ char *XML2NODE::GetText(char *buf, int len)
xmlFree(Content); xmlFree(Content);
if ((Content = xmlNodeGetContent(Nodep))) { if ((Content = xmlNodeGetContent(Nodep))) {
char *p1, *p2; char *p1 = (char*)Content, *p2 = buf;
bool b = false; bool b = false;
int rc = ((PXDOC2)Doc)->Decode(Content, buf, len);
#if 0 // Copy content eliminating extra characters
// Eliminate extra characters for (; *p1 && (p2 - buf) < (len - 1); p1++)
for (p1 = p2 = buf; *p1; p1++) if (strchr("\t\r\n", *p1)) {
if (strchr(" \t\r\n", *p1)) {
if (b) { if (b) {
// This to have one blank between sub-nodes
*p2++ = ' '; *p2++ = ' ';
b = false; b = false;
} // endif b } // endif b
@@ -485,14 +486,10 @@ char *XML2NODE::GetText(char *buf, int len)
b = true; b = true;
} // endif p1 } // endif p1
if (*(p2 - 1) == ' ') *p2 = 0;
*(p2 - 1) = 0;
else
*p2 = 0;
#endif // 0
if (trace) if (trace)
htrc("GetText buf='%s' len=%d rc=%d\n", buf, len, rc); htrc("GetText buf='%s' len=%d\n", buf, len);
xmlFree(Content); xmlFree(Content);
Content = NULL; Content = NULL;
@@ -507,10 +504,13 @@ char *XML2NODE::GetText(char *buf, int len)
/******************************************************************/ /******************************************************************/
bool XML2NODE::SetContent(PGLOBAL g, char *txtp, int len) bool XML2NODE::SetContent(PGLOBAL g, char *txtp, int len)
{ {
if (trace) xmlChar *buf = xmlEncodeEntitiesReentrant(Docp, BAD_CAST txtp);
htrc("SetContent %s\n", txtp);
xmlNodeSetContent(Nodep, ((PXDOC2)Doc)->Encode(g, txtp)); if (trace)
htrc("SetContent %s -> %s\n", txtp, buf);
xmlNodeSetContent(Nodep, buf);
xmlFree(buf);
return false; return false;
} // end of SetContent } // end of SetContent
@@ -772,8 +772,8 @@ XML2ATTR::XML2ATTR(PXDOC dp, xmlAttrPtr ap, xmlNodePtr np)
bool XML2ATTR::SetText(PGLOBAL g, char *txtp, int len) bool XML2ATTR::SetText(PGLOBAL g, char *txtp, int len)
{ {
if (trace) if (trace)
htrc("SetText %s\n", txtp); htrc("SetText %s %d\n", txtp, len);
xmlSetProp(Parent, Atrp->name, ((PXDOC2)Doc)->Encode(g, txtp)); xmlSetProp(Parent, Atrp->name, BAD_CAST txtp);
return false; return false;
} // end of SetText } // end of SetText

View File

@@ -53,7 +53,7 @@ class LIBXMLDOC : public XMLDOCUMENT {
virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn); virtual PFBLOCK LinkXblock(PGLOBAL g, MODE m, int rc, char *fn);
protected: protected:
bool CheckDocument(FILE *of, xmlNodePtr np); // bool CheckDocument(FILE *of, xmlNodePtr np);
xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp); xmlNodeSetPtr GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp);
int Decode(xmlChar *cnt, char *buf, int n); int Decode(xmlChar *cnt, char *buf, int n);
xmlChar *Encode(PGLOBAL g, char *txt); xmlChar *Encode(PGLOBAL g, char *txt);