Fix possible deadlock in css content attribute

develop
Nimetu 3 years ago
parent a40ddf7955
commit 285cfb163f

@ -1296,6 +1296,7 @@ namespace NLGUI
} }
std::string::size_type pos = 0; std::string::size_type pos = 0;
// TODO: tokenize by whitespace
while(pos < content.size()) while(pos < content.size())
{ {
std::string::size_type start; std::string::size_type start;
@ -1328,6 +1329,9 @@ namespace NLGUI
start = pos + 4; start = pos + 4;
// fails if url contains ')' // fails if url contains ')'
pos = content.find(")", start); pos = content.find(")", start);
if (pos == std::string::npos)
break;
token = trim(content.substr(start, pos - start)); token = trim(content.substr(start, pos - start));
// skip ')' // skip ')'
pos++; pos++;
@ -1390,14 +1394,22 @@ namespace NLGUI
{ {
// attr(title) // attr(title)
start = pos + 5; start = pos + 5;
pos = content.find(")", start); std::string::size_type end = 0;
token = content.substr(start, pos - start); end = content.find(")", start);
// skip ')' if (end != std::string::npos)
pos++;
if (elm.hasAttribute(token))
{ {
addString(elm.getAttribute(token)); token = content.substr(start, end - start);
// skip ')'
pos = end + 1;
if (elm.hasAttribute(token))
{
addString(elm.getAttribute(token));
}
}
else
{
// skip over 'a'
pos++;
} }
} }
else else

Loading…
Cancel
Save