summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2014-06-08 01:10:33 +0000
committerRené Schümann <white06tiger@gmail.com>2014-06-08 01:10:33 +0000
commit5baafa881a2ec9206eeac155fe4bfc0659c2af5c (patch)
tree59743f445501e2b55581a3d28bd8e0228a39f819 /plugins/SendScreenshotPlus
parent5f22034a2628515959a190a22b057512e0fa75a4 (diff)
SendSS:
! fixed possible crash (CSendHost_uploadpie, CSendImageShack) * improved ImageShack error handling by improving GetHTMLContent * improved uploadpie error handling (still ugly, but better non the less) git-svn-id: http://svn.miranda-ng.org/main/trunk@9421 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus')
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp9
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp15
-rw-r--r--plugins/SendScreenshotPlus/src/CSendImageShack.cpp4
3 files changed, 17 insertions, 11 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index a2f8e51beb..f0c800004e 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -454,9 +454,12 @@ void CSend::Exit(unsigned int Result) {
const char* CSend::GetHTMLContent(char* str, const char* startTag, const char* endTag) {
char* begin=strstr(str,startTag);
if(!begin) return NULL;
- begin+=strlen(startTag);
- char* end=strstr(begin,endTag);
- if(end) *end=0;
+ begin+=strlen(startTag)-1;
+ for(; *begin!='>' && *begin; ++begin);
+ if(*begin){
+ char* end=strstr(++begin,endTag);
+ if(end) *end=0;
+ }
return begin;
}
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
index 0218956559..6a2c7fe48a 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
@@ -67,8 +67,8 @@ void CSendHost_UploadPie::SendThread(void* obj)
NETLIBHTTPREQUEST* reply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlibUser,(LPARAM)&self->m_nlhr);
self->HTTPFormDestroy(&self->m_nlhr);
if(reply){
- if(reply->resultCode>=200 && reply->resultCode<300){
- reply->pData[reply->dataLength]='\0';/// make sure its null terminated
+ if(reply->resultCode>=200 && reply->resultCode<300 && reply->dataLength){
+ reply->pData[reply->dataLength-1]='\0';/// make sure its null terminated
char* url=reply->pData;
do{
char* pos;
@@ -76,7 +76,7 @@ void CSendHost_UploadPie::SendThread(void* obj)
for(pos=url+21; (*pos>='0'&&*pos<='9') || (*pos>='a'&&*pos<='z') || (*pos>='A'&&*pos<='Z') || *pos=='_' || *pos=='-' || *pos=='"' || *pos=='\''; ++pos){
if(*pos=='"' || *pos=='\'') break;
}
- if(*pos=='"' || *pos=='\''){
+ if(url+21!=pos && (*pos=='"' || *pos=='\'')){
*pos='\0';
break;
}
@@ -88,9 +88,12 @@ void CSendHost_UploadPie::SendThread(void* obj)
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)reply);
self->svcSendMsgExit(url); return;
}else{/// check error mess from server
- TCHAR* err=mir_a2t(reply->pData);
- self->Error(_T("%s"),err);
- mir_free(err);
+ const char* err=GetHTMLContent(reply->pData,"<p id=\"error\"","</p>");
+ TCHAR* werr;
+ if(err) werr=mir_a2t(err);
+ else werr=mir_a2t(reply->pData);
+ self->Error(_T("%s"),werr);
+ mir_free(werr);
}
}else{
self->Error(LPGENT("Upload server did not respond timely."));
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
index c12eed48fe..9bd0ef0e0f 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
@@ -72,8 +72,8 @@ void CSendImageShack::SendThread() {
NETLIBHTTPREQUEST* reply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&m_nlhr);
HTTPFormDestroy(&m_nlhr);
if(reply){
- if(reply->resultCode>=200 && reply->resultCode<300){
- reply->pData[reply->dataLength]='\0';/// make sure its null terminated
+ if(reply->resultCode>=200 && reply->resultCode<300 && reply->dataLength){
+ reply->pData[reply->dataLength-1]='\0';/// make sure its null terminated
const char* url=NULL;
url=GetHTMLContent(reply->pData,"<image_link>","</image_link>");
if(url && *url){