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,17 +1394,25 @@ 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);
if (end != std::string::npos)
{
token = content.substr(start, end - start);
// skip ')' // skip ')'
pos++; pos = end + 1;
if (elm.hasAttribute(token)) if (elm.hasAttribute(token))
{ {
addString(elm.getAttribute(token)); addString(elm.getAttribute(token));
} }
} }
else else
{
// skip over 'a'
pos++;
}
}
else
{ {
pos++; pos++;
} }

Loading…
Cancel
Save