From o2on-svn @ lists.sourceforge.jp Wed Jan 7 18:14:00 2009 From: o2on-svn @ lists.sourceforge.jp (o2on svn commit) Date: Wed, 07 Jan 2009 18:14:00 +0900 Subject: [o2on-svn] =?utf-8?b?WzEzM10gIDY044OT44OD44OI54mI44Gu44OT44Or44OJ?= =?utf-8?b?44GM6YCa44KJ44Gq44GP44Gq44Gj44Gm44GE44Gf44Gu44Gn44CB5L+u5q2j?= Message-ID: <1231319640.126239.16399.nullmailer@users.sourceforge.jp> Revision: 133 http://svn.sourceforge.jp/view?root=o2on&view=rev&rev=133 Author: osa_p Date: 2009-01-07 18:13:59 +0900 (Wed, 07 Jan 2009) Log Message: ----------- 64ビット版のビルドが通らなくなっていたので、修正 Modified Paths: -------------- trunk/o2on/src.o2on/o2on.vcproj Modified: trunk/o2on/src.o2on/o2on.vcproj =================================================================== --- trunk/o2on/src.o2on/o2on.vcproj 2008-11-30 16:34:08 UTC (rev 132) +++ trunk/o2on/src.o2on/o2on.vcproj 2009-01-07 09:13:59 UTC (rev 133) @@ -133,13 +133,14 @@ /> + + + + + + Revision: 134 http://svn.sourceforge.jp/view?root=o2on&view=rev&rev=134 Author: osa_p Date: 2009-01-07 18:14:54 +0900 (Wed, 07 Jan 2009) Log Message: ----------- ??В?с?????????????荅宴?????????????????????????紊????筝?????????????????荀????????????с? Modified Paths: -------------- trunk/o2on/src.o2on/O2Server_HTTP_P2P.h trunk/o2on/src.o2on/O2Version.h Modified: trunk/o2on/src.o2on/O2Server_HTTP_P2P.h =================================================================== --- trunk/o2on/src.o2on/O2Server_HTTP_P2P.h 2009-01-07 09:13:59 UTC (rev 133) +++ trunk/o2on/src.o2on/O2Server_HTTP_P2P.h 2009-01-07 09:14:54 UTC (rev 134) @@ -270,7 +270,9 @@ ss->Unlock(); path = "ERROR"; } - else if (node.o2ver() < PROTOCOL_VER) { + else if (( node.o2ver() < ACCEPT_PROTOCOL_VER_MIN ) || + ( ACCEPT_PROTOCOL_VER_MAX < node.o2ver() )) { + // ????????????????? ss->Lock(); MakeResponse_403(Profile, ss->sbuff); ss->Unlock(); Modified: trunk/o2on/src.o2on/O2Version.h =================================================================== --- trunk/o2on/src.o2on/O2Version.h 2009-01-07 09:13:59 UTC (rev 133) +++ trunk/o2on/src.o2on/O2Version.h 2009-01-07 09:14:54 UTC (rev 134) @@ -1,5 +1,7 @@ -#define PROTOCOL_NAME "O2" -#define PROTOCOL_VER 0.2 +#define PROTOCOL_NAME "O2" // ?????? +#define PROTOCOL_VER 0.2 // ?????????? +#define ACCEPT_PROTOCOL_VER_MIN 0.2 // ??????????????????? +#define ACCEPT_PROTOCOL_VER_MAX 0.2 // ??????????????????j #define APP_NAME "o2on" #define APP_VER_MAJOR 0 From o2on-svn @ lists.sourceforge.jp Sun Feb 1 03:42:59 2009 From: o2on-svn @ lists.sourceforge.jp (o2on svn commit) Date: Sun, 01 Feb 2009 03:42:59 +0900 Subject: [o2on-svn] =?utf-8?b?WzEzNV0gRklYOiAgIzEzNDc5IOeuoeeQhueUu+mdog==?= =?utf-8?b?44GMU2FmYXJp5pyq5a++5b+c?= Message-ID: <1233427379.073690.13774.nullmailer@users.sourceforge.jp> Revision: 135 http://svn.sourceforge.jp/view?root=o2on&view=rev&rev=135 Author: electrolysis Date: 2009-02-01 03:42:58 +0900 (Sun, 01 Feb 2009) Log Message: ----------- FIX: #13479 管理画面がSafari未対応 ブロードキャストで空文字列がPOSTされたことになる件の修正 Ticket Links: :----------- http://sourceforge.jp/projects/o2on/tracker/detail/13479 Modified Paths: -------------- trunk/o2on/admin/im.xsl Modified: trunk/o2on/admin/im.xsl =================================================================== --- trunk/o2on/admin/im.xsl 2009-01-07 09:14:54 UTC (rev 134) +++ trunk/o2on/admin/im.xsl 2009-01-31 18:42:58 UTC (rev 135) @@ -5,8 +5,9 @@ -
- + + +
From o2on-svn @ lists.sourceforge.jp Wed Feb 4 01:54:13 2009 From: o2on-svn @ lists.sourceforge.jp (o2on svn commit) Date: Wed, 04 Feb 2009 01:54:13 +0900 Subject: [o2on-svn] =?utf-8?b?WzEzNl0gIFNBWOWRqOi+uuOBruaUueiJrw==?= Message-ID: <1233680053.883418.25143.nullmailer@users.sourceforge.jp> Revision: 136 http://svn.sourceforge.jp/view?root=o2on&view=rev&rev=136 Author: electrolysis Date: 2009-02-04 01:54:13 +0900 (Wed, 04 Feb 2009) Log Message: ----------- SAX周辺の改良 詳細:単一要素内でContentHandler::characters()が複数回呼ばれる可能性を考慮し、予期せぬデータロスを防ぐ Modified Paths: -------------- trunk/o2on/src.o2on/O2Boards.cpp trunk/o2on/src.o2on/O2Boards.h trunk/o2on/src.o2on/O2IMDB.cpp trunk/o2on/src.o2on/O2IMDB.h trunk/o2on/src.o2on/O2IPFilter.cpp trunk/o2on/src.o2on/O2IPFilter.h trunk/o2on/src.o2on/O2KeyDB.cpp trunk/o2on/src.o2on/O2KeyDB.h trunk/o2on/src.o2on/O2NodeDB.cpp trunk/o2on/src.o2on/O2NodeDB.h trunk/o2on/src.o2on/O2PerformanceCounter.h trunk/o2on/src.o2on/O2Profile.cpp trunk/o2on/src.o2on/O2Profile.h trunk/o2on/src.o2on/upnp_description.h Modified: trunk/o2on/src.o2on/O2Boards.cpp =================================================================== --- trunk/o2on/src.o2on/O2Boards.cpp 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2Boards.cpp 2009-02-03 16:54:13 UTC (rev 136) @@ -906,6 +906,17 @@ , const XMLCh* const localname , const XMLCh* const qname) { + switch (parse_elm) { + case 1: + parse_name = buf; + break; + case 2: + parse_enable = buf[0] == L'0' ? false : true; + break; + } + + buf = L""; + parse_elm = 0; if (MATCHLNAME(L"board")) { ExLock.Lock(); @@ -927,12 +938,6 @@ characters(const XMLCh* const chars , const unsigned int length) { - switch (parse_elm) { - case 1: - parse_name.assign(chars, length); - break; - case 2: - parse_enable = chars[0] == L'0' ? false : true; - break; - } + if (parse_elm != 0) + buf.append(chars, length); } Modified: trunk/o2on/src.o2on/O2Boards.h =================================================================== --- trunk/o2on/src.o2on/O2Boards.h 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2Boards.h 2009-02-03 16:54:13 UTC (rev 136) @@ -89,6 +89,7 @@ uint parse_elm; wstring parse_name; bool parse_enable; + wstring buf; wchar_t *host2domain(const wchar_t *host); Modified: trunk/o2on/src.o2on/O2IMDB.cpp =================================================================== --- trunk/o2on/src.o2on/O2IMDB.cpp 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2IMDB.cpp 2009-02-03 16:54:13 UTC (rev 136) @@ -725,59 +725,64 @@ , const XMLCh* const localname , const XMLCh* const qname) { - CurElm = IM_XMLELM_NONE; - if (!CurIM || !MATCHLNAME(L"message")) - return; - - IMDB->AddMessage(*CurIM); -} - - - - -void -O2IMDB_SAX2Handler:: -characters(const XMLCh* const chars, const unsigned int length) -{ - if (!CurIM) - return; - switch (CurElm) { case IM_XMLELM_IP: - CurIM->ip = e2ip(chars, length); + CurIM->ip = e2ip(buf.c_str(), buf.size()); break; case IM_XMLELM_PORT: - CurIM->port = (ushort)wcstoul(chars, NULL, 10); + CurIM->port = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case IM_XMLELM_ID: - CurIM->id.assign(chars, length); + CurIM->id.assign(buf.c_str(), buf.size()); break; case IM_XMLELM_PUBKEY: - CurIM->pubkey.assign(chars, length); + CurIM->pubkey.assign(buf.c_str(), buf.size()); break; case IM_XMLELM_NAME: - CurIM->name.assign(chars, length); + CurIM->name = buf; break; case IM_XMLELM_DATE: - CurIM->date = datetime2time_t(chars, length); + CurIM->date = datetime2time_t(buf.c_str(), buf.size()); break; case IM_XMLELM_MSG: - CurIM->msg.assign(chars, length); + CurIM->msg = buf; break; case IM_XMLELM_KEY: - CurIM->key.assign(chars, length); + CurIM->key.assign(buf.c_str(), buf.size()); break; case IM_XMLELM_MINE: - CurIM->mine = chars[0] == L'0' ? false : true; + CurIM->mine = buf[0] == L'0' ? false : true; break; case IM_XMLELM_PATH: { hashT id; - id.assign(chars, length); + id.assign(buf.c_str(), buf.size()); CurIM->paths.push_back(id); while (CurIM->paths.size() > O2_BROADCAST_PATH_LIMIT) CurIM->paths.pop_front(); } break; } + + buf = L""; + + CurElm = IM_XMLELM_NONE; + if (!CurIM || !MATCHLNAME(L"message")) + return; + + IMDB->AddMessage(*CurIM); } + + + + +void +O2IMDB_SAX2Handler:: +characters(const XMLCh* const chars, const unsigned int length) +{ + if (!CurIM) + return; + + if (CurElm != IM_XMLELM_NONE) + buf.append(chars, length); +} Modified: trunk/o2on/src.o2on/O2IMDB.h =================================================================== --- trunk/o2on/src.o2on/O2IMDB.h 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2IMDB.h 2009-02-03 16:54:13 UTC (rev 136) @@ -157,18 +157,6 @@ size_t ExportToXML(O2IMSelectCondition &cond, string &out); size_t ImportFromXML(const wchar_t *filename, const char *in, uint len); - -public: - void endDocument(void); - void startElement(const XMLCh* const uri - , const XMLCh* const localname - , const XMLCh* const qname - , const Attributes& attrs); - void endElement(const XMLCh* const uri - , const XMLCh* const localname - , const XMLCh* const qname); - void characters(const XMLCh* const chars - , const unsigned int length); }; @@ -185,6 +173,7 @@ O2IMessage *CurIM; uint CurElm; size_t ParseNum; + wstring buf; public: O2IMDB_SAX2Handler(O2Logger *lgr, O2IMDB *imdb); Modified: trunk/o2on/src.o2on/O2IPFilter.cpp =================================================================== --- trunk/o2on/src.o2on/O2IPFilter.cpp 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2IPFilter.cpp 2009-02-03 16:54:13 UTC (rev 136) @@ -592,44 +592,49 @@ , const XMLCh* const localname , const XMLCh* const qname) { - CurElm = IPF_XMLELM_NONE; - - if (!CurRecord || !MATCHLNAME(L"filter")) - return; - if (CurRecord->cond.empty()) - return; - - IPFilter->add(CurRecord->enable, CurRecord->flag, CurRecord->cond.c_str()); -} - - - - -void -O2IPFilter_SAX2Handler:: -characters(const XMLCh* const chars, const unsigned int length) -{ switch (CurElm) { case IPF_XMLELM_DEFAULT: - if (_wcsnicmp(chars, L"allow", 5) == 0) + if (_wcsnicmp(buf.c_str(), L"allow", 5) == 0) IPFilter->setdefault(O2_ALLOW); else IPFilter->setdefault(O2_DENY); break; case IPF_XMLELM_ENABLE: - if (_wcsnicmp(chars, L"true", 4) == 0) + if (_wcsnicmp(buf.c_str(), L"true", 4) == 0) CurRecord->enable = true; else CurRecord->enable = false; break; case IPF_XMLELM_FLAG: - if (_wcsnicmp(chars, L"allow", 5) == 0) + if (_wcsnicmp(buf.c_str(), L"allow", 5) == 0) CurRecord->flag = O2_ALLOW; else CurRecord->flag = O2_DENY; break; case IPF_XMLELM_COND: - CurRecord->cond.assign(chars, length); + CurRecord->cond = buf; break; } + + buf = L""; + + CurElm = IPF_XMLELM_NONE; + + if (!CurRecord || !MATCHLNAME(L"filter")) + return; + if (CurRecord->cond.empty()) + return; + + IPFilter->add(CurRecord->enable, CurRecord->flag, CurRecord->cond.c_str()); } + + + + +void +O2IPFilter_SAX2Handler:: +characters(const XMLCh* const chars, const unsigned int length) +{ + if (CurElm != IPF_XMLELM_NONE) + buf.append(chars, length); +} Modified: trunk/o2on/src.o2on/O2IPFilter.h =================================================================== --- trunk/o2on/src.o2on/O2IPFilter.h 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2IPFilter.h 2009-02-03 16:54:13 UTC (rev 136) @@ -115,6 +115,7 @@ O2IPFilterRecord *CurRecord; uint CurElm; uint64 ParseNum; + wstring buf; public: O2IPFilter_SAX2Handler(const wchar_t *nm, O2Logger *lgr, O2IPFilter *ipf); Modified: trunk/o2on/src.o2on/O2KeyDB.cpp =================================================================== --- trunk/o2on/src.o2on/O2KeyDB.cpp 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2KeyDB.cpp 2009-02-03 16:54:13 UTC (rev 136) @@ -831,53 +831,58 @@ , const XMLCh* const localname , const XMLCh* const qname) { - CurElm = KEY_XMLELM_NONE; - if (!CurKey || !MATCHLNAME(L"key")) - return; - - KeyDB->AddKey(*CurKey); - ParseNum++; -} - -void -O2KeyDB_SAX2Handler:: -characters(const XMLCh* const chars, const unsigned int length) -{ - if (CurKey == NULL) - return; - switch (CurElm) { case KEY_XMLELM_HASH: - CurKey->hash.assign(chars, length); + CurKey->hash.assign(buf.c_str(), buf.size()); break; case KEY_XMLELM_NODEID: - CurKey->nodeid.assign(chars, length); + CurKey->nodeid.assign(buf.c_str(), buf.size()); break; case KEY_XMLELM_IP: - CurKey->ip = e2ip(chars, length); + CurKey->ip = e2ip(buf.c_str(), buf.size()); break; case KEY_XMLELM_PORT: - CurKey->port = (ushort)wcstoul(chars, NULL, 10); + CurKey->port = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case KEY_XMLELM_SIZE: - CurKey->size = wcstoul(chars, NULL, 10); + CurKey->size = wcstoul(buf.c_str(), NULL, 10); break; case KEY_XMLELM_URL: - CurKey->url.assign(chars, length); + CurKey->url = buf; break; case KEY_XMLELM_TITLE: - if (length <= O2_MAX_KEY_TITLE_LEN) - CurKey->title.assign(chars, length); + if (buf.size() <= O2_MAX_KEY_TITLE_LEN) + CurKey->title = buf; break; case KEY_XMLELM_NOTE: - if (length <= O2_MAX_KEY_NOTE_LEN) - CurKey->note.assign(chars, length); + if (buf.size() <= O2_MAX_KEY_NOTE_LEN) + CurKey->note = buf; break; case KEY_XMLELM_DATE: - CurKey->date = datetime2time_t(chars, length); + CurKey->date = datetime2time_t(buf.c_str(), buf.size()); break; case KEY_XMLELM_ENABLE: - CurKey->enable = chars[0] == L'e' ? true : false; + CurKey->enable = buf[0] == L'e' ? true : false; break; } + + buf = L""; + + CurElm = KEY_XMLELM_NONE; + if (!CurKey || !MATCHLNAME(L"key")) + return; + + KeyDB->AddKey(*CurKey); + ParseNum++; } + +void +O2KeyDB_SAX2Handler:: +characters(const XMLCh* const chars, const unsigned int length) +{ + if (CurKey == NULL) + return; + + if (CurElm != KEY_XMLELM_NONE) + buf.append(chars, length); +} Modified: trunk/o2on/src.o2on/O2KeyDB.h =================================================================== --- trunk/o2on/src.o2on/O2KeyDB.h 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2KeyDB.h 2009-02-03 16:54:13 UTC (rev 136) @@ -150,6 +150,7 @@ O2Key *CurKey; uint CurElm; uint64 ParseNum; + wstring buf; public: O2KeyDB_SAX2Handler(O2Logger *lgr, O2KeyDB *kdb); Modified: trunk/o2on/src.o2on/O2NodeDB.cpp =================================================================== --- trunk/o2on/src.o2on/O2NodeDB.cpp 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2NodeDB.cpp 2009-02-03 16:54:13 UTC (rev 136) @@ -585,47 +585,52 @@ , const XMLCh* const localname , const XMLCh* const qname) { - CurElm = NODE_XMLELM_NONE; - if (!CurNode || !MATCHLNAME(L"node")) - return; - - if (ReceiveList) - ReceiveList->push_back(*CurNode); - else - NodeDB->touch(*CurNode); - ParseNum++; -} - -void -O2NodeDB_SAX2Handler:: -characters(const XMLCh* const chars, const unsigned int length) -{ string tmpstr; - if (CurNode == NULL && CurElm != NODE_XMLELM_STR) - return; - switch (CurElm) { case NODE_XMLELM_ID: - CurNode->id.assign(chars, length); + CurNode->id.assign(buf.c_str(), buf.size()); break; case NODE_XMLELM_IP: - CurNode->ip = e2ip(chars, length); + CurNode->ip = e2ip(buf.c_str(), buf.size()); break; case NODE_XMLELM_PORT: - CurNode->port = (ushort)wcstoul(chars, NULL, 10); + CurNode->port = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case NODE_XMLELM_NAME: - if (length <= O2_MAX_NAME_LEN) - CurNode->name.assign(chars, length); + if (buf.size() <= O2_MAX_NAME_LEN) + CurNode->name = buf; break; case NODE_XMLELM_PUBKEY: - CurNode->pubkey.assign(chars, length); + CurNode->pubkey.assign(buf.c_str(), buf.size()); break; case NODE_XMLELM_STR: - unicode2ascii(chars, length, tmpstr); + unicode2ascii(buf, tmpstr); if (NodeDB->AddEncodedNode(tmpstr.c_str(), tmpstr.size())) ParseNum++; break; } + + buf = L""; + + CurElm = NODE_XMLELM_NONE; + if (!CurNode || !MATCHLNAME(L"node")) + return; + + if (ReceiveList) + ReceiveList->push_back(*CurNode); + else + NodeDB->touch(*CurNode); + ParseNum++; } + +void +O2NodeDB_SAX2Handler:: +characters(const XMLCh* const chars, const unsigned int length) +{ + if (CurNode == NULL && CurElm != NODE_XMLELM_STR) + return; + + if (CurElm != NODE_XMLELM_NONE) + buf.append(chars, length); +} Modified: trunk/o2on/src.o2on/O2NodeDB.h =================================================================== --- trunk/o2on/src.o2on/O2NodeDB.h 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2NodeDB.h 2009-02-03 16:54:13 UTC (rev 136) @@ -117,6 +117,7 @@ O2Node *CurNode; uint CurElm; size_t ParseNum; + wstring buf; public: O2NodeDB_SAX2Handler(O2Logger *lgr, O2NodeDB *ndb, O2NodeDB::NodeListT *rlist); Modified: trunk/o2on/src.o2on/O2PerformanceCounter.h =================================================================== --- trunk/o2on/src.o2on/O2PerformanceCounter.h 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2PerformanceCounter.h 2009-02-03 16:54:13 UTC (rev 136) @@ -45,6 +45,7 @@ uint64 Total_Send; uint64 Total_Recv; uint64 *pval; + wstring buf; public: O2PerformanceCounter(const wchar_t *name @@ -262,6 +263,9 @@ , const XMLCh* const localname , const XMLCh* const qname) { + if (pval) + *pval = _wcstoui64(buf.c_str(), NULL, 10); + buf = L""; pval = NULL; } void characters(const XMLCh* const chars @@ -269,6 +273,6 @@ { if (!pval) return; - *pval = _wcstoui64(chars, NULL, 10); + buf.append(chars, length); } }; Modified: trunk/o2on/src.o2on/O2Profile.cpp =================================================================== --- trunk/o2on/src.o2on/O2Profile.cpp 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2Profile.cpp 2009-02-03 16:54:13 UTC (rev 136) @@ -1670,104 +1670,100 @@ , const XMLCh* const localname , const XMLCh* const qname) { - CurElm = PROF_XMLELM_NONE; - if (!MATCHLNAME(L"profile")) - return; - - if (Profile->PrivKey.size() != RSA_PRIVKEY_SIZE - || Profile->PubKey.size() != RSA_PUBKEY_SIZE) { - Profile->SetRSAKey(NULL, 0, NULL, 0); - } -} - - - - -void -O2Profile_SAX2Handler:: -characters(const XMLCh* const chars, const unsigned int length) -{ - wstring str; - switch (CurElm) { case PROF_XMLELM_ID: - Profile->ID.assign(chars, length); + Profile->ID.assign(buf.c_str(), buf.size()); break; case PROF_XMLELM_PRIVKEY: - Profile->PrivKey.assign(chars, length); + Profile->PrivKey.assign(buf.c_str(), buf.size()); break; case PROF_XMLELM_PUBKEY: - Profile->PubKey.assign(chars, length); + Profile->PubKey.assign(buf.c_str(), buf.size()); break; case PROF_XMLELM_IP: - Profile->IP = e2ip(chars, length); + Profile->IP = e2ip(buf.c_str(), buf.size()); break; case PROF_XMLELM_P2PPORT: - Profile->P2PPort = (ushort)wcstoul(chars, NULL, 10); + Profile->P2PPort = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case PROF_XMLELM_PROXYPORT: - Profile->ProxyPort = (ushort)wcstoul(chars, NULL, 10); + Profile->ProxyPort = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case PROF_XMLELM_ADMINPORT: - Profile->AdminPort = (ushort)wcstoul(chars, NULL, 10); + Profile->AdminPort = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case PROF_XMLELM_NAME: - if (length <= O2_MAX_NAME_LEN) { - str.assign(chars, length); - Profile->SetNodeName(str.c_str()); + if (buf.size() <= O2_MAX_NAME_LEN) { + Profile->SetNodeName(buf.c_str()); } break; case PROF_XMLELM_COMMENT: - if (length <= O2_MAX_COMMENT_LEN) { - for (size_t i = 0; i < length; i++) { - if (chars[i] == L'\n') + if (buf.size() <= O2_MAX_COMMENT_LEN) { + for (size_t i = 0; i < buf.size(); i++) { + if (buf[i] == L'\n') Profile->Comment += L"\r\n"; else - Profile->Comment += chars[i]; + Profile->Comment += buf[i]; } } break; case PROF_XMLELM_DBDIR: - str.assign(chars, length); - Profile->SetDBDir(str.c_str()); + Profile->SetDBDir(buf.c_str()); break; case PROF_XMLELM_CACHEROOT: - str.assign(chars, length); - Profile->SetCacheRoot(str.c_str()); + Profile->SetCacheRoot(buf.c_str()); break; case PROF_XMLELM_ADMINROOT: - str.assign(chars, length); - Profile->SetAdminRoot(str.c_str()); + Profile->SetAdminRoot(buf.c_str()); break; case PROF_XMLELM_ADMIN_BROWSER_TYPE: - Profile->AdminBrowserType.assign(chars, length); + Profile->AdminBrowserType = buf; break; case PROF_XMLELM_ADMIN_BROWSER_PATH: - Profile->AdminBrowserPath.assign(chars, length); + Profile->AdminBrowserPath = buf; break; case PROF_XMLELM_UPNP_ADAPTERNAME: - str.assign(chars, length); - unicode2ascii(str, Profile->UPnPAdapterName); + unicode2ascii(buf, Profile->UPnPAdapterName); break; case PROF_XMLELM_UPNP_LOCATION: - str.assign(chars, length); - unicode2ascii(str, Profile->UPnPLocation); + unicode2ascii(buf, Profile->UPnPLocation); break; case PROF_XMLELM_UPNP_SERVICEID: - str.assign(chars, length); - unicode2ascii(str, Profile->UPnPServiceId); + unicode2ascii(buf, Profile->UPnPServiceId); break; case PROF_XMLELM_LIMIT: if (plimit) - *plimit = wcstoul(chars, NULL, 10); + *plimit = wcstoul(buf.c_str(), NULL, 10); break; case PROF_XMLELM_SIZE_T: if (puint64) - *puint64 = _wcstoui64(chars, NULL, 10); + *puint64 = _wcstoui64(buf.c_str(), NULL, 10); break; case PROF_XMLELM_BOOL: - *pbool = chars[0] == '1' ? true : false; + *pbool = buf[0] == '1' ? true : false; break; } + + buf = L""; + + CurElm = PROF_XMLELM_NONE; + if (!MATCHLNAME(L"profile")) + return; + + if (Profile->PrivKey.size() != RSA_PRIVKEY_SIZE + || Profile->PubKey.size() != RSA_PUBKEY_SIZE) { + Profile->SetRSAKey(NULL, 0, NULL, 0); + } } + + + + +void +O2Profile_SAX2Handler:: +characters(const XMLCh* const chars, const unsigned int length) +{ + if (CurElm != PROF_XMLELM_NONE) + buf.append(chars, length); +} Modified: trunk/o2on/src.o2on/O2Profile.h =================================================================== --- trunk/o2on/src.o2on/O2Profile.h 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/O2Profile.h 2009-02-03 16:54:13 UTC (rev 136) @@ -308,7 +308,7 @@ // -// O2NodeDB_SAX2Handler +// O2Profile_SAX2Handler // class O2Profile_SAX2Handler : public SAX2Handler @@ -320,6 +320,7 @@ uint *plimit; uint64 *puint64; bool *pbool; + wstring buf; public: O2Profile_SAX2Handler(O2Logger *lgr, O2Profile *prof); Modified: trunk/o2on/src.o2on/upnp_description.h =================================================================== --- trunk/o2on/src.o2on/upnp_description.h 2009-01-31 18:42:58 UTC (rev 135) +++ trunk/o2on/src.o2on/upnp_description.h 2009-02-03 16:54:13 UTC (rev 136) @@ -210,6 +210,8 @@ UPnPService *cur_service; std::list parents; + wstring buf; + inline bool matchlname(const wchar_t *a, const wchar_t *b) { return (_wcsicmp(a, b) == 0 ? true : false); @@ -304,35 +306,16 @@ cur_service = new UPnPService; cur_service->rootObject = object; } + + buf = L""; } void endElement(const XMLCh* const uri , const XMLCh* const localname , const XMLCh* const qname) { - if (matchlname(localname, L"device")) { - if (!parents.empty()) { - parents.back()->deviceList.push_back(*cur_device); - delete cur_device; - cur_device = parents.back(); - parents.pop_back(); - } - } - else if (matchlname(localname, L"service")) { - if (cur_device) { - cur_device->serviceList.push_back(*cur_service); - delete cur_service; - cur_service = NULL; - } - } - - cur_element = L""; - } - - void characters(const XMLCh* const chars, const unsigned int length) - { string str; - unicode2ascii(chars, length, str); + unicode2ascii(buf, str); if (wcsstr(cur_element.c_str(), L"URLBase")) { if (str[str.size()-1] == '/') @@ -380,8 +363,34 @@ else if (matchelement(L"eventSubURL")) cur_service->eventSubURL = str; } + + buf =L""; + + if (matchlname(localname, L"device")) { + if (!parents.empty()) { + parents.back()->deviceList.push_back(*cur_device); + delete cur_device; + cur_device = parents.back(); + parents.pop_back(); + } + } + else if (matchlname(localname, L"service")) { + if (cur_device) { + cur_device->serviceList.push_back(*cur_service); + delete cur_service; + cur_service = NULL; + } + } + + cur_element = L""; } + void characters(const XMLCh* const chars, const unsigned int length) + { + if (!cur_element.empty()) + buf.append(chars, length); + } + void warning(const SAXParseException& e) { if (MessageHandler) { @@ -433,6 +442,8 @@ UPnPAction *cur_action; UPnPArgument *cur_argument; + wstring buf; + inline bool matchlname(const wchar_t *a, const wchar_t *b) { return (_wcsicmp(a, b) == 0 ? true : false); @@ -514,12 +525,32 @@ else if (matchlname(localname, L"argument")) { cur_argument = new UPnPArgument; } + + buf = L""; } void endElement(const XMLCh* const uri , const XMLCh* const localname , const XMLCh* const qname) { + string str; + unicode2ascii(buf, str); + + if (cur_argument) { + if (matchelement(L"name")) + cur_argument->name = str; + else if (matchelement(L"direction")) + cur_argument->direction = str; + else if (matchelement(L"relatedStateVariable")) + cur_argument->relatedStateVariable = str; + } + else if (cur_action) { + if (matchelement(L"name")) + cur_action->name = str; + } + + buf = L""; + if (matchlname(localname, L"action")) { if (cur_action) { service->actionList.push_back(*cur_action); @@ -541,21 +572,8 @@ void characters(const XMLCh* const chars, const unsigned int length) { - string str; - unicode2ascii(chars, length, str); - - if (cur_argument) { - if (matchelement(L"name")) - cur_argument->name = str; - else if (matchelement(L"direction")) - cur_argument->direction = str; - else if (matchelement(L"relatedStateVariable")) - cur_argument->relatedStateVariable = str; - } - else if (cur_action) { - if (matchelement(L"name")) - cur_action->name = str; - } + if (!cur_element.empty()) + buf.append(chars, length); } void warning(const SAXParseException& e) @@ -608,6 +626,8 @@ UPnPAction *cur_action; UPnPArgument *cur_argument; + wstring buf; + public: UPnPSOAPResponseParser(UPnPService *sv, void (*func)(const char *)) : service(sv) @@ -701,9 +721,12 @@ , const XMLCh* const localname , const XMLCh* const qname) { - string name; - unicode2ascii(localname, wcslen(localname), name); + if (cur_argument) { + unicode2ascii(buf, cur_argument->value); + } + buf = L""; + if (wcsncmp(qname, L"m:", 2) == 0) { cur_action = NULL; } @@ -714,11 +737,8 @@ void characters(const XMLCh* const chars, const unsigned int length) { - string str; - unicode2ascii(chars, length, str); - if (cur_argument) { - unicode2ascii(chars, length, cur_argument->value); + buf.append(chars, length); } } From o2on-svn @ lists.sourceforge.jp Mon Feb 9 22:16:32 2009 From: o2on-svn @ lists.sourceforge.jp (o2on svn commit) Date: Mon, 09 Feb 2009 22:16:32 +0900 Subject: [o2on-svn] =?utf-8?b?WzEzN10gIOmBqeWIh+OBq0NEQVRB44K744Kv44K344On?= =?utf-8?b?44Oz44KS5L2c44KL6Zai5pWw44KS6Kit44GR44Gf?= Message-ID: <1234185392.132771.6168.nullmailer@users.sourceforge.jp> Revision: 137 http://svn.sourceforge.jp/view?root=o2on&view=rev&rev=137 Author: electrolysis Date: 2009-02-09 22:16:31 +0900 (Mon, 09 Feb 2009) Log Message: ----------- ?????DATA?祉??激??潟?篏???∽???┃??? Modified Paths: -------------- trunk/o2on/src.o2on/O2DatIO.cpp trunk/o2on/src.o2on/O2IMDB.cpp trunk/o2on/src.o2on/O2KeyDB.cpp trunk/o2on/src.o2on/O2Logger.cpp trunk/o2on/src.o2on/O2NodeDB.cpp trunk/o2on/src.o2on/O2Profile.cpp trunk/o2on/src.o2on/O2ReportMaker.cpp trunk/o2on/src.o2on/O2Server_HTTP_Admin.h trunk/o2on/src.o2on/dataconv.cpp trunk/o2on/src.o2on/dataconv.h Modified: trunk/o2on/src.o2on/O2DatIO.cpp =================================================================== --- trunk/o2on/src.o2on/O2DatIO.cpp 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/O2DatIO.cpp 2009-02-09 13:16:31 UTC (rev 137) @@ -679,9 +679,10 @@ xml += L""; xml += it->url; xml += L""EOL; - xml += L"<![CDATA["; - xml += it->title; - xml += L"]]>"EOL; + makeCDATA(it->title, tmpstr); + xml += L""; + xml += tmpstr; + xml += L""EOL; swprintf_s(tmp, 32, L"%I64u", it->size); xml += L""; xml += tmp; Modified: trunk/o2on/src.o2on/O2IMDB.cpp =================================================================== --- trunk/o2on/src.o2on/O2IMDB.cpp 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/O2IMDB.cpp 2009-02-09 13:16:31 UTC (rev 137) @@ -276,9 +276,10 @@ xml += profile->GetNodeNameW(); xml += L""EOL; - xml += L" "EOL; + makeCDATA(msg, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; xml += L""EOL; xml += L""EOL; @@ -329,9 +330,10 @@ xml += im.name; xml += L""EOL; - xml += L" "EOL; + makeCDATA(im.msg, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; im.key.to_string(tmpstr); xml += L" "; @@ -565,9 +567,10 @@ } if (cond.mask & IM_XMLELM_MSG) { - xml += L" "EOL; + makeCDATA(im.msg, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } if (cond.mask & IM_XMLELM_KEY) { Modified: trunk/o2on/src.o2on/O2KeyDB.cpp =================================================================== --- trunk/o2on/src.o2on/O2KeyDB.cpp 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/O2KeyDB.cpp 2009-02-09 13:16:31 UTC (rev 137) @@ -634,15 +634,17 @@ } if (cond.mask & KEY_XMLELM_TITLE) { - xml += L" <![CDATA["; - xml += key.title; - xml += L"]]>"EOL; + makeCDATA(key.title, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } if (cond.mask & KEY_XMLELM_NOTE) { - xml += L" "EOL; + makeCDATA(key.note, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } if (cond.mask & KEY_XMLELM_IDKEYHASH) { Modified: trunk/o2on/src.o2on/O2Logger.cpp =================================================================== --- trunk/o2on/src.o2on/O2Logger.cpp 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/O2Logger.cpp 2009-02-09 13:16:31 UTC (rev 137) @@ -365,9 +365,10 @@ } if (cond.mask & LOG_XMLELM_MODULE) { - xml += L" "EOL; + makeCDATA(rec.module, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } if (cond.mask & LOG_XMLELM_IP) { @@ -395,9 +396,10 @@ } if (cond.mask & LOG_XMLELM_MSG) { - xml += L" "EOL; + makeCDATA(rec.msg, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } xml += L""EOL; Modified: trunk/o2on/src.o2on/O2NodeDB.cpp =================================================================== --- trunk/o2on/src.o2on/O2NodeDB.cpp 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/O2NodeDB.cpp 2009-02-09 13:16:31 UTC (rev 137) @@ -351,9 +351,10 @@ xml += L""EOL; } if (cond.mask & NODE_XMLELM_NAME) { - xml += L" "EOL; + makeCDATA(node.name, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } if (cond.mask & NODE_XMLELM_PUBKEY) { node.pubkey.to_string(tmpstr); Modified: trunk/o2on/src.o2on/O2Profile.cpp =================================================================== --- trunk/o2on/src.o2on/O2Profile.cpp 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/O2Profile.cpp 2009-02-09 13:16:31 UTC (rev 137) @@ -1186,18 +1186,18 @@ //NodeName if (cond.mask & PROF_XMLELM_NAME) { - //convertGTLT(NodeName, tmpstr); - xml += L" "EOL; + makeCDATA(NodeNameW, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } //Comment if (cond.mask & PROF_XMLELM_COMMENT) { - //convertGTLT(Comment, tmpstr); - xml += L" "EOL; + makeCDATA(Comment, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } //P2PPort @@ -1242,23 +1242,26 @@ //DBDir if (cond.mask & PROF_XMLELM_DBDIR) { - xml += L" "EOL; + makeCDATA(DBDirW, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } //CacheRoot if (cond.mask & PROF_XMLELM_CACHEROOT) { - xml += L" "EOL; + makeCDATA(CacheRootW, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } //AdminRoot if (cond.mask & PROF_XMLELM_ADMINROOT) { - xml += L" "EOL; + makeCDATA(AdminRootW, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } //AdminBrowserType @@ -1270,33 +1273,37 @@ //AdminBrowserPath if (cond.mask & PROF_XMLELM_ADMIN_BROWSER_PATH) { - xml += L" "EOL; + makeCDATA(AdminBrowserPath, tmpstr); + xml += L" "; + xml += tmpstr; + xml += L""EOL; } //UPnPAdapterName if (cond.mask & PROF_XMLELM_UPNP_ADAPTERNAME) { ascii2unicode(UPnPAdapterName, tmpstr); - xml += L" "; xml += tmpstr; - xml += L"]]>"EOL; + xml += L""EOL; } //UPnPLocation if (cond.mask & PROF_XMLELM_UPNP_LOCATION) { ascii2unicode(UPnPLocation, tmpstr); - xml += L" "; xml += tmpstr; - xml += L"]]>"EOL; + xml += L""EOL; } //UPnPServiceId if (cond.mask & PROF_XMLELM_UPNP_SERVICEID) { ascii2unicode(UPnPServiceId, tmpstr); - xml += L" "; xml += tmpstr; - xml += L"]]>"EOL; + xml += L""EOL; } //limits Modified: trunk/o2on/src.o2on/O2ReportMaker.cpp =================================================================== --- trunk/o2on/src.o2on/O2ReportMaker.cpp 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/O2ReportMaker.cpp 2009-02-09 13:16:31 UTC (rev 137) @@ -189,6 +189,7 @@ swprintf(publishper, 32, L"%.1f%% (%I64u)", (double)pubnum/datnum*100.0, pubnum); } + wstring tmpstr; wstring xml; xml += L"GetNodeNameW(); - xml += L"]]>"EOL; + makeCDATA(Profile->GetNodeNameW(), tmpstr); + xml += L""; + xml += tmpstr; + xml += L""EOL; xml += L""EOL; xml += L""EOL; // @@ -218,30 +220,34 @@ // xml += L""EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"????"); - xml += L"
GetComment();
-		xml += L"]]>
"EOL; + makeCDATA(Profile->GetComment(), tmpstr); + xml += L"
";
+		xml += tmpstr;
+		xml += L"
"EOL; xml += L""EOL; // if (Profile->IsPublicRecentDat()) { xml += L""EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"????"); - xml += L"
";
 			O2KeyList recent;
 			Server_Proxy->GetRecentDatList(recent);
+			tmpstr.erase();
 			for (O2KeyListIt it = recent.begin(); it != recent.end(); it++) {
 				wchar_t timestr[TIMESTR_BUFF_SIZE];
 				struct tm tm;
 				localtime_s(&tm, &it->date);
 				wcsftime(timestr, TIMESTR_BUFF_SIZE, L"%Y/%m/%d %H:%M:%S", &tm);
-				xml += timestr;
-				xml += L" [ ";
-				xml += it->url;
-				xml += L" ] ";
-				xml += it->title;
-				xml += L"\r\n";
+				tmpstr += timestr;
+				tmpstr += L" [ ";
+				tmpstr += it->url;
+				tmpstr += L" ] ";
+				tmpstr += it->title;
+				tmpstr += L"\r\n";
 			}
-			xml += L"]]>
"EOL; + makeCDATA(tmpstr, tmpstr); + xml += tmpstr; + xml += L""EOL; xml += L""EOL; } xml += L"
"EOL; Modified: trunk/o2on/src.o2on/O2Server_HTTP_Admin.h =================================================================== --- trunk/o2on/src.o2on/O2Server_HTTP_Admin.h 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/O2Server_HTTP_Admin.h 2009-02-09 13:16:31 UTC (rev 137) @@ -1654,13 +1654,15 @@ void GET_xml_sql(O2SocketSession *ss) { wstring str; - wstring escaped; + wstring tmpstr; str += L""; str += L""; - escapeCDATA(sql, escaped); - str += L""; + makeCDATA(sql, tmpstr); + str += L""; + str += tmpstr; + str += L""; if (!sqlresult.empty()) { wchar_t tmp[16]; swprintf_s(tmp, 16, L"%u", sqlresult.size()-1); @@ -1671,11 +1673,17 @@ for (size_t i = 0; i < sqlresult.size(); i++) { str += L""; for (size_t j = 0; j < sqlresult[i].size(); j++) { - escapeCDATA(sqlresult[i][j], escaped); - if (i == 0) - str += L""; - else - str += L""; + makeCDATA(sqlresult[i][j], tmpstr); + if (i == 0) { + str += L""; + str += tmpstr; + str += L""; + } + else { + str += L""; + str += tmpstr; + str += L""; + } } str += L""; } Modified: trunk/o2on/src.o2on/dataconv.cpp =================================================================== --- trunk/o2on/src.o2on/dataconv.cpp 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/dataconv.cpp 2009-02-09 13:16:31 UTC (rev 137) @@ -810,7 +810,7 @@ // --------------------------------------------------------------------------- // convertGTLT -// escapeCDATA +// makeCDATA // --------------------------------------------------------------------------- void convertGTLT(const string &in, string &out) { @@ -838,25 +838,33 @@ out = t.str(); } -void escapeCDATA(const string &in, string &out) +void makeCDATA(const string &in, string &out) { - out = string(in); + string tmp = in; string from = "]]>"; string to = "]]]]>"; - for (size_t pos = 0; (pos = out.find(from, pos)) != string::npos; pos += to.size()) - out.replace(pos, from.size(), to); + for (size_t pos = 0; (pos = tmp.find(from, pos)) != string::npos; pos += to.size()) + tmp.replace(pos, from.size(), to); + + out = ""; } -void escapeCDATA(const wstring &in, wstring &out) +void makeCDATA(const wstring &in, wstring &out) { - out = wstring(in); + wstring tmp = in; wstring from = L"]]>"; wstring to = L"]]]]>"; - for (size_t pos = 0; (pos = out.find(from, pos)) != string::npos; pos += to.size()) - out.replace(pos, from.size(), to); + for (size_t pos = 0; (pos = tmp.find(from, pos)) != string::npos; pos += to.size()) + tmp.replace(pos, from.size(), to); + + out = L""; } @@ -869,6 +877,8 @@ void xml_AddElement(wstring &xml, const wchar_t *tag, const wchar_t *attr, const wchar_t *val, bool escape) { + wstring tmp; + xml += L'<'; xml += tag; if (attr) { @@ -876,9 +886,12 @@ xml += attr; } xml += L'>'; - if (escape) xml += L""; + if (escape) { + makeCDATA(val, tmp); + xml += tmp; + } + else + xml += val; xml += L"\r\n"; Modified: trunk/o2on/src.o2on/dataconv.h =================================================================== --- trunk/o2on/src.o2on/dataconv.h 2009-02-03 16:54:13 UTC (rev 136) +++ trunk/o2on/src.o2on/dataconv.h 2009-02-09 13:16:31 UTC (rev 137) @@ -78,8 +78,8 @@ void convertGTLT(const string &in, string &out); void convertGTLT(const wstring &in, wstring &out); -extern void escapeCDATA(const string &in, string &out); -extern void escapeCDATA(const wstring &in, wstring &out); +extern void makeCDATA(const string &in, string &out); +extern void makeCDATA(const wstring &in, wstring &out); extern void xml_AddElement(wstring &xml, const wchar_t *tag, const wchar_t *attr, const wchar_t *val, bool escape = false); extern void xml_AddElement(wstring &xml, const wchar_t *tag, const wchar_t *attr, int val);