Revisión | a50bb214e077c63f88d56f74814702df32b04df5 (tree) |
---|---|
Tiempo | 2012-03-26 00:43:07 |
Autor | qwerty2501 <qwerty2501@user...> |
Commiter | qwerty2501 |
Safariクッキー取得処理実装
@@ -50,11 +50,11 @@ inline const T * memmem(const T *base, ULong count, const void *pattern,UInt | ||
50 | 50 | } |
51 | 51 | |
52 | 52 | // 最初に一致する位置を探す |
53 | - const Byte *start = static_cast<const Byte *>( base ); | |
53 | + const Byte *start = reinterpret_cast<const Byte *>( base ); | |
54 | 54 | for( const Byte *p = start;p + length <= start + count;++p ){ |
55 | 55 | if ( 0 == memcmp( p, pattern, length ) ) |
56 | 56 | { |
57 | - return const_cast<Byte *>( p ); | |
57 | + return reinterpret_cast<const T *>( p ); | |
58 | 58 | } |
59 | 59 | } |
60 | 60 |
@@ -364,13 +364,15 @@ CHResult CRegistryKey::QueryValue(const NString &valueName,Int &val,LPDWORD lpTy | ||
364 | 364 | |
365 | 365 | Bool CFindFirstFile::NextFile(WIN32_FIND_DATA &findData){ |
366 | 366 | |
367 | - return FindNextFile(m_handle,&findData); | |
367 | + return FindNextFile(m_handle,&findData) != FALSE; | |
368 | 368 | } |
369 | 369 | |
370 | 370 | HANDLE CFindFirstFile::Find(const NString &fileName,WIN32_FIND_DATA &findData){ |
371 | 371 | |
372 | + if(m_handle == nullptr){ | |
372 | 373 | |
373 | - m_handle = FindFirstFile(fileName.c_str(),&findData); | |
374 | + m_handle = FindFirstFile(fileName.c_str(),&findData); | |
375 | + } | |
374 | 376 | |
375 | 377 | return m_handle; |
376 | 378 | } |
@@ -54,15 +54,18 @@ Bool CChromeCookieGetter::Fancta(const Byte * data,ULong dataSize,const NString | ||
54 | 54 | |
55 | 55 | MString searchString; |
56 | 56 | ToUTF8(searchString,domein+name); |
57 | - const Char *startPointer = reinterpret_cast<const Char*>(memmem(data,dataSize,searchString.c_str(),searchString.size()) +searchString.size()) ; | |
57 | + const Char *startPointer = reinterpret_cast<const Char*>(memmem(data,dataSize,searchString.c_str(),searchString.size()) ) ; | |
58 | 58 | |
59 | - U16String cookieValue; | |
60 | - UTF8ToUTF16(cookieValue,startPointer,strstr(startPointer,"/") - startPointer); | |
61 | - if(!cookieValue.empty() ){ | |
59 | + if(startPointer != nullptr){ | |
60 | + startPointer += searchString.size(); | |
61 | + U16String cookieValue; | |
62 | + UTF8ToUTF16(cookieValue,startPointer,strstr(startPointer,"/") - startPointer); | |
63 | + if(!cookieValue.empty() ){ | |
62 | 64 | |
63 | - cookie.SetCookieValue(cookieValue); | |
64 | - return true; | |
65 | + cookie.SetCookieValue(cookieValue); | |
66 | + return true; | |
65 | 67 | |
68 | + } | |
66 | 69 | } |
67 | 70 | return false; |
68 | 71 | } |
@@ -75,9 +75,10 @@ Bool CFireFoxCookieGetter::Fancta(const Byte * data,ULong dataSize,const NString | ||
75 | 75 | ToUTF8(mdomein,_T(".") + domein); |
76 | 76 | ToUTF8(startdomeinname,domein+name); |
77 | 77 | |
78 | - const Char * startPointer = reinterpret_cast<const Char*>(memmem(data,dataSize,startdomeinname.c_str(),startdomeinname.size())+ startdomeinname.size()); | |
78 | + const Char * startPointer = reinterpret_cast<const Char*>(memmem(data,dataSize,startdomeinname.c_str(),startdomeinname.size())); | |
79 | 79 | |
80 | 80 | if(startPointer != nullptr){ |
81 | + startPointer += startdomeinname.size(); | |
81 | 82 | U16String cookieValue; |
82 | 83 | UTF8ToUTF16(cookieValue,startPointer,strstr(startPointer,mdomein.c_str()) - startPointer); |
83 | 84 | cookie.SetCookieValue(cookieValue); |
@@ -50,7 +50,10 @@ protected: | ||
50 | 50 | |
51 | 51 | if(hresult.IsSucceded()){ |
52 | 52 | |
53 | - cookie.SetCookieValue(buf.data()); | |
53 | + NString val = buf.data(); | |
54 | + nregex reg(name + _T("=")); | |
55 | + val = std::regex_replace(val,reg,NString(_T(""))); | |
56 | + cookie.SetCookieValue(val); | |
54 | 57 | result.SetFindFlag(true); |
55 | 58 | } else { |
56 | 59 |
@@ -70,7 +73,31 @@ protected: | ||
70 | 73 | static Bool Fancta(const Byte * data,ULong dataSize,const NString & domein,const NString &name,CCookie &cookie){ |
71 | 74 | |
72 | 75 | |
73 | - return false; | |
76 | + MString mname; | |
77 | + MString mdomein; | |
78 | + ToUTF8(mname,name); | |
79 | + ToUTF8(mdomein,domein); | |
80 | + | |
81 | + const Char *keyStartPointer = strstr(reinterpret_cast<const Char*>(data),mname.c_str()); | |
82 | + | |
83 | + if(keyStartPointer == nullptr)return false; | |
84 | + const Char *cookieStartPointer = strstr(keyStartPointer,"\n"); | |
85 | + | |
86 | + if(cookieStartPointer == nullptr)return false; | |
87 | + | |
88 | + cookieStartPointer++; | |
89 | + | |
90 | + const Char *cookieEndPointer = strstr(cookieStartPointer,"\n"); | |
91 | + | |
92 | + const Char *astorStartPointer = strstr(cookieEndPointer+1,"*"); | |
93 | + const Char *domeinStartPointer = strstr(cookieEndPointer+1,mdomein.c_str()); | |
94 | + if(astorStartPointer == nullptr || domeinStartPointer == nullptr || astorStartPointer <= domeinStartPointer)return false; | |
95 | + Int cookieBufSize = cookieEndPointer - cookieStartPointer; | |
96 | + U16String val; | |
97 | + UTF8ToUTF16(val,cookieStartPointer,cookieBufSize); | |
98 | + cookie.SetCookieValue(val); | |
99 | + | |
100 | + return true; | |
74 | 101 | } |
75 | 102 | |
76 | 103 | template<typename F> |
@@ -82,10 +109,10 @@ protected: | ||
82 | 109 | NString targetFileName; |
83 | 110 | WIN32_FIND_DATA findData; |
84 | 111 | |
85 | - | |
112 | + if(findfirst.Find(searchFiles,findData) == INVALID_HANDLE_VALUE)return result; | |
86 | 113 | |
87 | 114 | do{ |
88 | - if(findfirst.Find(searchFiles,findData) != INVALID_HANDLE_VALUE)break; | |
115 | + | |
89 | 116 | |
90 | 117 | if((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == false){ |
91 | 118 |
@@ -94,6 +121,7 @@ protected: | ||
94 | 121 | if(ForceSearch(targetFileName,domein,name,cookie,func)){ |
95 | 122 | |
96 | 123 | result.SetFindFlag(true); |
124 | + break; | |
97 | 125 | } |
98 | 126 | } |
99 | 127 |
@@ -0,0 +1,30 @@ | ||
1 | +#include "stdafx.h" | |
2 | +#include "iecomponentcookiegetter.h" | |
3 | + | |
4 | +#include "namespace_start.h" | |
5 | + | |
6 | +browsertype::BrowserType CIEComponentGetter::BT = browsertype::IECOMPONENT; | |
7 | + | |
8 | +Bool CIEComponentGetter::GetCookieInternal(const NString &domein,const NString &name,CCookie &cookie){ | |
9 | + | |
10 | + CCookieGetResult result = this->GetCookieIEAPI(domein,name,cookie,false); | |
11 | + | |
12 | + if(result.GetResultCode() != resultcode::OK){ | |
13 | + | |
14 | + resultList.push_back(result); | |
15 | + CCookieGetResult forceresult = CIEComponentGetter::ForceSearchFiles(this->normalDirectry,domein,name,cookie,CIEComponentGetter::Fancta); | |
16 | + | |
17 | + if(forceresult.GetResultCode() != resultcode::OK){ | |
18 | + | |
19 | + resultList.push_back(forceresult); | |
20 | + } | |
21 | + | |
22 | + } | |
23 | + | |
24 | + | |
25 | + | |
26 | + return result.IsFound(); | |
27 | +} | |
28 | + | |
29 | + | |
30 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -0,0 +1,15 @@ | ||
1 | +#pragma once | |
2 | + | |
3 | +#include "ieapicookiegetter.h" | |
4 | + | |
5 | +#include "namespace_start.h" | |
6 | + | |
7 | +class CIEComponentGetter:public CIEAPICookieGetterT<CIEComponentGetter>{ | |
8 | + friend Void UnitTest(); | |
9 | +public: | |
10 | + Bool GetCookieInternal(const NString &domein,const NString &name,CCookie &cookie); | |
11 | + | |
12 | + | |
13 | +}; | |
14 | + | |
15 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -13,22 +13,23 @@ CIECookieGetter::CIECookieGetter(){ | ||
13 | 13 | |
14 | 14 | Bool CIECookieGetter::GetCookieInternal(const NString &domein,const NString &name,CCookie &cookie){ |
15 | 15 | |
16 | - NString url = _T("http://") + domein; | |
17 | 16 | Bool secFlag = IEIsSecurityMode(); |
18 | - CCookieGetResult result = this->GetCookieIEAPI(url,name,cookie,secFlag); | |
17 | + CCookieGetResult result = this->GetCookieIEAPI(domein,name,cookie,secFlag); | |
19 | 18 | |
20 | 19 | if(result.GetResultCode() != resultcode::OK){ |
21 | 20 | |
22 | 21 | resultList.push_back(result); |
22 | + CCookieGetResult forceresult = CIECookieGetter::ForceSearchFiles(secFlag ? this->securityCookiedir : this->normalDirectry,domein,name,cookie,CIECookieGetter::Fancta); | |
23 | 23 | |
24 | - } | |
25 | - | |
24 | + if(forceresult.GetResultCode() != resultcode::OK){ | |
26 | 25 | |
27 | - if(!result.IsFound()){ | |
26 | + resultList.push_back(forceresult); | |
27 | + } | |
28 | 28 | |
29 | - CIECookieGetter::ForceSearchFiles(secFlag ? this->securityCookiedir : this->normalDirectry,domein,name,cookie,CIECookieGetter::Fancta); | |
30 | 29 | } |
31 | 30 | |
31 | + | |
32 | + | |
32 | 33 | return result.IsFound(); |
33 | 34 | } |
34 | 35 |
@@ -5,7 +5,7 @@ | ||
5 | 5 | #include "namespace_start.h" |
6 | 6 | class CIECookieGetter:public CIEAPICookieGetterT<CIECookieGetter>{ |
7 | 7 | friend Void UnitTest(); |
8 | - | |
8 | + typedef CIEAPICookieGetterT<CIECookieGetter> Base; | |
9 | 9 | private: |
10 | 10 | NString securityCookiedir; |
11 | 11 |
@@ -103,6 +103,7 @@ | ||
103 | 103 | </ItemGroup> |
104 | 104 | <ItemGroup> |
105 | 105 | <ClInclude Include="chromecookiegetter.h" /> |
106 | + <ClInclude Include="iecomponentcookiegetter.h" /> | |
106 | 107 | <ClInclude Include="cookie.h" /> |
107 | 108 | <ClInclude Include="cookieGetResult.h" /> |
108 | 109 | <ClInclude Include="cookieGetter.h" /> |
@@ -114,6 +115,8 @@ | ||
114 | 115 | <ClInclude Include="iecookiegetter.h" /> |
115 | 116 | <ClInclude Include="namespace_end.h" /> |
116 | 117 | <ClInclude Include="namespace_start.h" /> |
118 | + <ClInclude Include="operacookiegetter.h" /> | |
119 | + <ClInclude Include="safaricookiegetter.h" /> | |
117 | 120 | <ClInclude Include="sqlitecookiegetter.h" /> |
118 | 121 | <ClInclude Include="stdafx.h" /> |
119 | 122 | <ClInclude Include="targetver.h" /> |
@@ -124,7 +127,10 @@ | ||
124 | 127 | <ClCompile Include="cookie.cpp" /> |
125 | 128 | <ClCompile Include="cookieGetResult.cpp" /> |
126 | 129 | <ClCompile Include="firefoxcookiegetter.cpp" /> |
130 | + <ClCompile Include="iecomponentcookiegetter.cpp" /> | |
127 | 131 | <ClCompile Include="iecookiegetter.cpp" /> |
132 | + <ClCompile Include="operacookiegetter.cpp" /> | |
133 | + <ClCompile Include="safaricookiegetter.cpp" /> | |
128 | 134 | <ClCompile Include="stdafx.cpp"> |
129 | 135 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> |
130 | 136 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='UnitTest|Win32'">Create</PrecompiledHeader> |
@@ -66,6 +66,15 @@ | ||
66 | 66 | <ClInclude Include="iecookiegetter.h"> |
67 | 67 | <Filter>ヘッダー ファイル</Filter> |
68 | 68 | </ClInclude> |
69 | + <ClInclude Include="iecomponentcookiegetter.h"> | |
70 | + <Filter>ヘッダー ファイル</Filter> | |
71 | + </ClInclude> | |
72 | + <ClInclude Include="operacookiegetter.h"> | |
73 | + <Filter>ヘッダー ファイル</Filter> | |
74 | + </ClInclude> | |
75 | + <ClInclude Include="safaricookiegetter.h"> | |
76 | + <Filter>ヘッダー ファイル</Filter> | |
77 | + </ClInclude> | |
69 | 78 | </ItemGroup> |
70 | 79 | <ItemGroup> |
71 | 80 | <ClCompile Include="stdafx.cpp"> |
@@ -89,5 +98,14 @@ | ||
89 | 98 | <ClCompile Include="iecookiegetter.cpp"> |
90 | 99 | <Filter>ソース ファイル</Filter> |
91 | 100 | </ClCompile> |
101 | + <ClCompile Include="iecomponentcookiegetter.cpp"> | |
102 | + <Filter>ソース ファイル</Filter> | |
103 | + </ClCompile> | |
104 | + <ClCompile Include="operacookiegetter.cpp"> | |
105 | + <Filter>ソース ファイル</Filter> | |
106 | + </ClCompile> | |
107 | + <ClCompile Include="safaricookiegetter.cpp"> | |
108 | + <Filter>ソース ファイル</Filter> | |
109 | + </ClCompile> | |
92 | 110 | </ItemGroup> |
93 | 111 | </Project> |
\ No newline at end of file |
@@ -0,0 +1,76 @@ | ||
1 | +#include "stdafx.h" | |
2 | +#include "operacookiegetter.h" | |
3 | + | |
4 | + | |
5 | +#include "namespace_start.h" | |
6 | + | |
7 | +browsertype::BrowserType COperaCookieGetter::BT = browsertype::OPERA; | |
8 | + | |
9 | +COperaCookieGetter::COperaCookieGetter(): | |
10 | +Base(CreateCookiePath()) | |
11 | +{} | |
12 | + | |
13 | +Bool COperaCookieGetter::GetCookieInternal(const NString &domein,const NString &name,CCookie &cookie){ | |
14 | + | |
15 | + return ForceSearch(cookieFilePath,domein,name,cookie,COperaCookieGetter::Fancta); | |
16 | + | |
17 | + | |
18 | +} | |
19 | + | |
20 | +Bool COperaCookieGetter::Fancta(const Byte * data,ULong dataSize,const NString & domein,const NString &name,CCookie &cookie){ | |
21 | + | |
22 | + MString mdomein; | |
23 | + ToUTF8(mdomein,domein); | |
24 | + std::regex reg(".jp"); | |
25 | + mdomein = std::regex_replace(mdomein,reg,MString("")); | |
26 | + MString mname; | |
27 | + ToUTF8(mname,name); | |
28 | + MString mval; | |
29 | + ULong dataSizetmp; | |
30 | + const Byte * startPointer = memmem(data,dataSize,mdomein.c_str(),mdomein.size()); | |
31 | + const Byte * nameStartPointer; | |
32 | + const Byte * cookieStartPointer; | |
33 | + if(startPointer != nullptr){ | |
34 | + | |
35 | + do{ | |
36 | + startPointer += mdomein.size(); | |
37 | + dataSizetmp = dataSize - (startPointer - data); | |
38 | + nameStartPointer = memmem(startPointer,dataSizetmp,mname.c_str(),mname.size()); | |
39 | + | |
40 | + if(nameStartPointer != nullptr){ | |
41 | + cookieStartPointer = nameStartPointer + mname.size() + 2; | |
42 | + if(cookieStartPointer != nullptr){ | |
43 | + | |
44 | + mval = reinterpret_cast<const Char*>(cookieStartPointer); | |
45 | + | |
46 | + std::regex reg2("([^a-z0-9_-])+"); | |
47 | + mval = std::regex_replace(mval,reg2,MString("")); | |
48 | + U16String val; | |
49 | + UTF8ToUTF16(val,mval); | |
50 | + cookie.SetCookieValue(val); | |
51 | + return !val.empty(); | |
52 | + | |
53 | + } | |
54 | + | |
55 | + } | |
56 | + | |
57 | + startPointer = memmem(startPointer,dataSizetmp,mdomein.c_str(),mdomein.size()); | |
58 | + }while(startPointer != nullptr); | |
59 | + | |
60 | + } | |
61 | + | |
62 | + return false; | |
63 | +} | |
64 | + | |
65 | +NString COperaCookieGetter::CreateCookiePath(){ | |
66 | + | |
67 | + NString cookieFilePath; | |
68 | + GetAppDataDirectry(cookieFilePath); | |
69 | + cookieFilePath += _T("\\Opera\\Opera\\cookies4.dat"); | |
70 | + | |
71 | + return cookieFilePath; | |
72 | + | |
73 | +} | |
74 | + | |
75 | + | |
76 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -0,0 +1,27 @@ | ||
1 | +#include "filecookiegetter.h" | |
2 | + | |
3 | + | |
4 | +#include "namespace_start.h" | |
5 | + | |
6 | + | |
7 | +class COperaCookieGetter:public CFileCookieGetterT<COperaCookieGetter>{ | |
8 | + | |
9 | + friend Void UnitTest(); | |
10 | + typedef CFileCookieGetterT<COperaCookieGetter> Base; | |
11 | +public: | |
12 | + | |
13 | + COperaCookieGetter(); | |
14 | + | |
15 | + | |
16 | + Bool GetCookieInternal(const NString &domein,const NString &name,CCookie &cookie); | |
17 | + | |
18 | + | |
19 | + static Bool Fancta(const Byte * data,ULong dataSize,const NString & domein,const NString &name,CCookie &cookie); | |
20 | + | |
21 | +private: | |
22 | + static NString CreateCookiePath(); | |
23 | + | |
24 | +}; | |
25 | + | |
26 | + | |
27 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -0,0 +1,75 @@ | ||
1 | +#include "stdafx.h" | |
2 | +#include "safaricookiegetter.h" | |
3 | + | |
4 | + | |
5 | +#include "namespace_start.h" | |
6 | + | |
7 | +browsertype::BrowserType CSafariCookieGetter::BT = browsertype::SAFARI; | |
8 | + | |
9 | +CSafariCookieGetter::CSafariCookieGetter(): | |
10 | +Base(CreateCookiePath()) | |
11 | +{} | |
12 | + | |
13 | +Bool CSafariCookieGetter::GetCookieInternal(const NString &domein,const NString &name,CCookie &cookie){ | |
14 | + | |
15 | + return ForceSearch(cookieFilePath,domein,name,cookie,CSafariCookieGetter::Fancta); | |
16 | + | |
17 | + | |
18 | +} | |
19 | + | |
20 | +Bool CSafariCookieGetter::Fancta(const Byte * data,ULong dataSize,const NString & domein,const NString &name,CCookie &cookie){ | |
21 | + | |
22 | + MString mdomein; | |
23 | + ToUTF8(mdomein,domein); | |
24 | + MString mname; | |
25 | + ToUTF8(mname,name); | |
26 | + MString mval; | |
27 | + ULong dataSizetmp; | |
28 | + const Byte * startPointer = memmem(data,dataSize,mname.c_str(),mname.size()); | |
29 | + const Byte * domeinStartPointer; | |
30 | + const Byte * cookieStartPointer; | |
31 | + if(startPointer != nullptr){ | |
32 | + | |
33 | + do{ | |
34 | + startPointer += mdomein.size(); | |
35 | + dataSizetmp = dataSize - (startPointer - data); | |
36 | + cookieStartPointer = memmem(startPointer,dataSizetmp,mname.c_str(),mname.size()); | |
37 | + domeinStartPointer = memmem(startPointer,dataSizetmp,mdomein.c_str(),mdomein.size()); | |
38 | + | |
39 | + if(domeinStartPointer != nullptr && mdomein == reinterpret_cast<const Char*>(domeinStartPointer)){ | |
40 | + | |
41 | + if(cookieStartPointer != nullptr){ | |
42 | + | |
43 | + mval = reinterpret_cast<const Char*>(cookieStartPointer); | |
44 | + | |
45 | + std::regex reg2("([^a-z0-9_-])+"); | |
46 | + mval = std::regex_replace(mval,reg2,MString("")); | |
47 | + U16String val; | |
48 | + UTF8ToUTF16(val,mval); | |
49 | + cookie.SetCookieValue(val); | |
50 | + return !val.empty(); | |
51 | + | |
52 | + } | |
53 | + | |
54 | + } | |
55 | + | |
56 | + startPointer = memmem(startPointer,dataSizetmp,mname.c_str(),mname.size()); | |
57 | + }while(startPointer != nullptr); | |
58 | + | |
59 | + } | |
60 | + | |
61 | + return false; | |
62 | +} | |
63 | + | |
64 | +NString CSafariCookieGetter::CreateCookiePath(){ | |
65 | + | |
66 | + NString cookieFilePath; | |
67 | + GetAppDataDirectry(cookieFilePath); | |
68 | + cookieFilePath += _T("\\Apple Computer\\Safari\\Cookies\\Cookies.binarycookies"); | |
69 | + | |
70 | + return cookieFilePath; | |
71 | + | |
72 | +} | |
73 | + | |
74 | + | |
75 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -0,0 +1,27 @@ | ||
1 | +#include "filecookiegetter.h" | |
2 | + | |
3 | + | |
4 | +#include "namespace_start.h" | |
5 | + | |
6 | + | |
7 | +class CSafariCookieGetter:public CFileCookieGetterT<CSafariCookieGetter>{ | |
8 | + | |
9 | + friend Void UnitTest(); | |
10 | + typedef CFileCookieGetterT<CSafariCookieGetter> Base; | |
11 | +public: | |
12 | + | |
13 | + CSafariCookieGetter(); | |
14 | + | |
15 | + | |
16 | + Bool GetCookieInternal(const NString &domein,const NString &name,CCookie &cookie); | |
17 | + | |
18 | + | |
19 | + static Bool Fancta(const Byte * data,ULong dataSize,const NString & domein,const NString &name,CCookie &cookie); | |
20 | + | |
21 | +private: | |
22 | + static NString CreateCookiePath(); | |
23 | + | |
24 | +}; | |
25 | + | |
26 | + | |
27 | +#include "namespace_end.h" | |
\ No newline at end of file |
@@ -5,6 +5,9 @@ | ||
5 | 5 | #include "cookie.h" |
6 | 6 | #include "chromecookiegetter.h" |
7 | 7 | #include "firefoxcookiegetter.h" |
8 | +#include "iecomponentcookiegetter.h" | |
9 | +#include "safaricookiegetter.h" | |
10 | +#include "operacookiegetter.h" | |
8 | 11 | #include "iecookiegetter.h" |
9 | 12 | #include "cookieGetter.h" |
10 | 13 | #include "unit_test.h" |
@@ -57,21 +60,10 @@ Void UnitTest(){ | ||
57 | 60 | |
58 | 61 | |
59 | 62 | |
60 | - /* | |
61 | - try{ | |
62 | 63 | |
63 | -// testGetter.ForceSearch(nullptr,0,_T("testdomein"),_T("testname"),cookie); | |
64 | - | |
65 | - } catch(Exception &e2){ | |
66 | - e2; | |
67 | - exceptionflag = true; | |
68 | - | |
69 | - } | |
70 | - | |
71 | - BOOST_CHECK_MESSAGE(exceptionflag == true,"CookieGetter関数実装エラーです"); | |
72 | - */ | |
73 | 64 | |
74 | 65 | { |
66 | + CCookie cookie1; | |
75 | 67 | BOOST_CHECK_MESSAGE(!CChromeCookieGetter::CreateCookiePath().empty(),"クロームのクッキーパス取得に失敗しました"); |
76 | 68 | CChromeCookieGetter chromeCookieGetter; |
77 | 69 | Bool result; |
@@ -80,7 +72,7 @@ Void UnitTest(){ | ||
80 | 72 | NString name = _T("user_session"); |
81 | 73 | try{ |
82 | 74 | |
83 | - result = chromeCookieGetter.GetCookie(domein,name,cookie); | |
75 | + result = chromeCookieGetter.GetCookie(domein,name,cookie1); | |
84 | 76 | |
85 | 77 | } catch(Exception &e3){ |
86 | 78 | e3; |
@@ -105,11 +97,54 @@ Void UnitTest(){ | ||
105 | 97 | BOOST_CHECK_MESSAGE(result2 == true,"クッキーが見つかりませんでした"); |
106 | 98 | |
107 | 99 | if(result && result2){ |
108 | - BOOST_CHECK_MESSAGE(cookie.GetCookieValue() == cookie2.GetCookieValue(),"正規の方法で取得したクッキーと強制検索で取得したクッキーが違います"); | |
100 | + BOOST_CHECK_MESSAGE(cookie1.GetCookieValue() == cookie2.GetCookieValue(),"正規の方法で取得したクッキーと強制検索で取得したクッキーが違います"); | |
109 | 101 | } |
110 | 102 | } |
103 | + | |
104 | + { | |
105 | + CCookie cookie1; | |
106 | + | |
107 | + COperaCookieGetter cookieGetter; | |
108 | + Bool result; | |
109 | + exceptionflag = false; | |
110 | + NString domein = _T("nicovideo.jp"); | |
111 | + NString name = _T("user_session"); | |
112 | + try{ | |
113 | + | |
114 | + result = cookieGetter.GetCookie(domein,name,cookie1); | |
115 | + | |
116 | + } catch(Exception &e3){ | |
117 | + e3; | |
118 | + exceptionflag = true; | |
119 | + } | |
120 | + | |
121 | + BOOST_CHECK_MESSAGE(exceptionflag == false,"クッキー検索中に例外が発生しました"); | |
122 | + BOOST_CHECK_MESSAGE(result == true,"クッキーが見つかりませんでした"); | |
123 | + } | |
124 | + | |
125 | + { | |
126 | + CCookie cookie1; | |
127 | + | |
128 | + CSafariCookieGetter cookieGetter; | |
129 | + Bool result; | |
130 | + exceptionflag = false; | |
131 | + NString domein = _T("nicovideo.jp"); | |
132 | + NString name = _T("user_session"); | |
133 | + try{ | |
134 | + | |
135 | + result = cookieGetter.GetCookie(domein,name,cookie1); | |
136 | + | |
137 | + } catch(Exception &e3){ | |
138 | + e3; | |
139 | + exceptionflag = true; | |
140 | + } | |
141 | + | |
142 | + BOOST_CHECK_MESSAGE(exceptionflag == false,"クッキー検索中に例外が発生しました"); | |
143 | + BOOST_CHECK_MESSAGE(result == true,"クッキーが見つかりませんでした"); | |
144 | + } | |
111 | 145 | |
112 | 146 | { |
147 | + CCookie cookie1; | |
113 | 148 | BOOST_CHECK_MESSAGE(!CFireFoxCookieGetter::CreateCookiePath().empty(),"クッキーパス取得に失敗しました"); |
114 | 149 | CFireFoxCookieGetter firefoxcookiegetter; |
115 | 150 | Bool result; |
@@ -118,7 +153,7 @@ Void UnitTest(){ | ||
118 | 153 | NString name = _T("user_session"); |
119 | 154 | try{ |
120 | 155 | |
121 | - result = firefoxcookiegetter.GetCookie(domein,name,cookie); | |
156 | + result = firefoxcookiegetter.GetCookie(domein,name,cookie1); | |
122 | 157 | |
123 | 158 | } catch(Exception &e3){ |
124 | 159 | e3; |
@@ -143,12 +178,12 @@ Void UnitTest(){ | ||
143 | 178 | BOOST_CHECK_MESSAGE(result2 == true,"クッキーが見つかりませんでした"); |
144 | 179 | |
145 | 180 | if(result && result2){ |
146 | - BOOST_CHECK_MESSAGE(cookie.GetCookieValue() == cookie2.GetCookieValue(),"正規の方法で取得したクッキーと強制検索で取得したクッキーが違います"); | |
181 | + BOOST_CHECK_MESSAGE(cookie1.GetCookieValue() == cookie2.GetCookieValue(),"正規の方法で取得したクッキーと強制検索で取得したクッキーが違います"); | |
147 | 182 | } |
148 | 183 | } |
149 | 184 | |
150 | 185 | { |
151 | - | |
186 | + CCookie cookie1; | |
152 | 187 | CIECookieGetter::IEIsSecurityMode(); |
153 | 188 | |
154 | 189 |
@@ -159,7 +194,51 @@ Void UnitTest(){ | ||
159 | 194 | NString name = _T("user_session"); |
160 | 195 | try{ |
161 | 196 | |
162 | - result = cookieGetters.GetCookie(domein,name,cookie); | |
197 | + result = cookieGetters.GetCookie(domein,name,cookie1); | |
198 | + | |
199 | + } catch(Exception &e3){ | |
200 | + e3; | |
201 | + exceptionflag = true; | |
202 | + } | |
203 | + | |
204 | + BOOST_CHECK_MESSAGE(exceptionflag == false,"クッキー検索中に例外が発生しました"); | |
205 | + BOOST_CHECK_MESSAGE(result == true,"クッキーが見つかりませんでした"); | |
206 | + | |
207 | + exceptionflag = true; | |
208 | + Bool result2 = false; | |
209 | + CCookie cookie2; | |
210 | + try{ | |
211 | + | |
212 | + CCookieGetResult result = cookieGetters.ForceSearchFiles(cookieGetters.securityCookiedir,domein,name,cookie2,CIECookieGetter::Fancta); | |
213 | + | |
214 | + result2 = result.IsFound(); | |
215 | + | |
216 | + } catch(Exception &e3){ | |
217 | + e3; | |
218 | + exceptionflag = true; | |
219 | + } | |
220 | + | |
221 | + BOOST_CHECK_MESSAGE(result2 == true,"クッキーが見つかりませんでした"); | |
222 | + | |
223 | + if(result && result2){ | |
224 | + BOOST_CHECK_MESSAGE(cookie1.GetCookieValue() == cookie2.GetCookieValue(),"正規の方法で取得したクッキーと強制検索で取得したクッキーが違います"); | |
225 | + } | |
226 | + | |
227 | + } | |
228 | + | |
229 | + | |
230 | + { | |
231 | + CCookie cookie1; | |
232 | + | |
233 | + | |
234 | + CIEComponentGetter cookieGetters; | |
235 | + Bool result; | |
236 | + exceptionflag = false; | |
237 | + NString domein = _T("nicovideo.jp"); | |
238 | + NString name = _T("user_session"); | |
239 | + try{ | |
240 | + | |
241 | + result = cookieGetters.GetCookie(domein,name,cookie1); | |
163 | 242 | |
164 | 243 | } catch(Exception &e3){ |
165 | 244 | e3; |
@@ -173,8 +252,10 @@ Void UnitTest(){ | ||
173 | 252 | Bool result2 = false; |
174 | 253 | CCookie cookie2; |
175 | 254 | try{ |
176 | - // result2 = ForceSearch(firefoxcookiegetter.cookieFilePath,domein,name,cookie2,CFireFoxCookieGetter::Fancta); | |
255 | + | |
256 | + CCookieGetResult result = cookieGetters.ForceSearchFiles(cookieGetters.normalDirectry,domein,name,cookie2,CIECookieGetter::Fancta); | |
177 | 257 | |
258 | + result2 = result.IsFound(); | |
178 | 259 | |
179 | 260 | } catch(Exception &e3){ |
180 | 261 | e3; |
@@ -184,7 +265,7 @@ Void UnitTest(){ | ||
184 | 265 | BOOST_CHECK_MESSAGE(result2 == true,"クッキーが見つかりませんでした"); |
185 | 266 | |
186 | 267 | if(result && result2){ |
187 | - BOOST_CHECK_MESSAGE(cookie.GetCookieValue() == cookie2.GetCookieValue(),"正規の方法で取得したクッキーと強制検索で取得したクッキーが違います"); | |
268 | + BOOST_CHECK_MESSAGE(cookie1.GetCookieValue() == cookie2.GetCookieValue(),"正規の方法で取得したクッキーと強制検索で取得したクッキーが違います"); | |
188 | 269 | } |
189 | 270 | |
190 | 271 | } |