Skip to content

Commit

Permalink
Fix a corner case where addHotSpot can be very slow.
Browse files Browse the repository at this point in the history
  • Loading branch information
Coises committed Mar 22, 2024
1 parent cccd99b commit 226e0f0
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3120,30 +3120,9 @@ bool isUrlQueryDelimiter(TCHAR const c)
return false;
}

bool isUrlSchemeSupported(INTERNET_SCHEME s, TCHAR *url)
bool isUrlSchemeSupported(TCHAR *url)
{
switch (s)
{
case INTERNET_SCHEME_FTP:
case INTERNET_SCHEME_HTTP:
case INTERNET_SCHEME_HTTPS:
case INTERNET_SCHEME_MAILTO:
case INTERNET_SCHEME_FILE:
return true;

case INTERNET_SCHEME_PARTIAL:
case INTERNET_SCHEME_UNKNOWN:
case INTERNET_SCHEME_DEFAULT:
case INTERNET_SCHEME_GOPHER:
case INTERNET_SCHEME_NEWS:
case INTERNET_SCHEME_SOCKS:
case INTERNET_SCHEME_JAVASCRIPT:
case INTERNET_SCHEME_VBSCRIPT:
case INTERNET_SCHEME_RES:
default:
break;
}
generic_string const mySchemes = (NppParameters::getInstance()).getNppGUI()._uriSchemes + TEXT(" ");
generic_string const mySchemes = L"ftp:// http:// https:// mailto: file:// " + (NppParameters::getInstance()).getNppGUI()._uriSchemes + TEXT(" ");
TCHAR *p = (TCHAR *)mySchemes.c_str();
while (*p)
{
Expand Down Expand Up @@ -3373,14 +3352,14 @@ bool isUrl(TCHAR * text, int textLen, int start, int* segmentLen)
return false;
}
int len = 0;
scanToUrlEnd (text, textLen, start + schemeLen, & len);
if (isUrlSchemeSupported(&text[start])) scanToUrlEnd (text, textLen, start + schemeLen, & len);
if (len)
{
len += schemeLen;
URL_COMPONENTS url;
memset (& url, 0, sizeof(url));
url.dwStructSize = sizeof(url);
bool r = InternetCrackUrl(& text [start], len, 0, & url) && isUrlSchemeSupported(url.nScheme, & text [start]);
bool r = InternetCrackUrl(& text [start], len, 0, & url);
if (r)
{
while (removeUnwantedTrailingCharFromUrl (& text [start], & len));
Expand Down

0 comments on commit 226e0f0

Please sign in to comment.