Skip to content

Commit

Permalink
version 0.4 Fix URL RegEx
Browse files Browse the repository at this point in the history
  • Loading branch information
Flyteas committed Mar 12, 2017
1 parent ad89e41 commit eea3390
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Binary file modified Struts2-045-Exp.v11.suo
Binary file not shown.
4 changes: 2 additions & 2 deletions Struts2-045-Exp/Exp.cpp
Expand Up @@ -272,12 +272,12 @@ CString Exp::httpPost(CString url,CString header,CString postData,DWORD& statusC
return resultPage;
}

/* URL解析 匹配正则表达式为 ((http|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-]*)? */
/* URL解析 匹配正则表达式为 ((http|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-!]*)? */
bool Exp::urlParse(CString url,int&httpType,CString& host,unsigned short int& port,CString& path)
{
CString httpPrefix = "http://";
CString httpsPrefix = "https://";
CString httpRegEx = "((http|https)://)(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\\&%_\\./-~-]*)?"; //URL匹配正则表达式
CString httpRegEx = "((http|https)://)(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\\&%_\\./-~-!]*)?"; //URL匹配正则表达式
url.Replace("\\","/"); //反斜杠换成斜杠
if(url.Mid(0,httpPrefix.GetLength()) != httpPrefix && url.Mid(0,httpsPrefix.GetLength()) != httpsPrefix) //输入的URL没有前缀
url = "http://" + url; //添加前缀
Expand Down

0 comments on commit eea3390

Please sign in to comment.