Fixed: Protocol-less url in windows
--HG-- branch : develop
This commit is contained in:
parent
9e0b38e6e0
commit
5d35bb8717
1 changed files with 11 additions and 24 deletions
|
@ -4625,27 +4625,15 @@ namespace NLGUI
|
||||||
result = url;
|
result = url;
|
||||||
string tmp;
|
string tmp;
|
||||||
|
|
||||||
// folder used for images cache
|
if (toLower(result).find("file:") == 0 && result.size() > 5)
|
||||||
static const string cacheDir = "cache";
|
|
||||||
|
|
||||||
string::size_type protocolPos = toLower(result).find("://");
|
|
||||||
|
|
||||||
if (protocolPos != string::npos)
|
|
||||||
{
|
|
||||||
// protocol present, it's an url so file must be searched in cache folder
|
|
||||||
// TODO: case of special characters & and ?
|
|
||||||
result = cacheDir + result.substr(protocolPos+2);
|
|
||||||
|
|
||||||
// if the file is already cached, use it
|
|
||||||
if (CFile::fileExists(result)) tmp = result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Url is a file ?
|
|
||||||
if (toLower(result).find("file:") == 0)
|
|
||||||
{
|
{
|
||||||
result = result.substr(5, result.size()-5);
|
result = result.substr(5, result.size()-5);
|
||||||
}
|
}
|
||||||
|
else if (result.find("://") != string::npos || result.find("//") == 0)
|
||||||
|
{
|
||||||
|
// http://, https://, etc or protocol-less url "//domain.com/image.png"
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
tmp = CPath::lookup (CFile::getFilename(result), false, false, false);
|
tmp = CPath::lookup (CFile::getFilename(result), false, false, false);
|
||||||
if (tmp.empty())
|
if (tmp.empty())
|
||||||
|
@ -4653,7 +4641,6 @@ namespace NLGUI
|
||||||
// try to find in local directory
|
// try to find in local directory
|
||||||
tmp = CPath::lookup (result, false, false, true);
|
tmp = CPath::lookup (result, false, false, true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!tmp.empty())
|
if (!tmp.empty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue