mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
svg_loader: correct parsing ColorStop offset values
Values different from numbers and percentages should be ignored and the default values should be applied (zeros).
This commit is contained in:
parent
cadbbb8028
commit
5679d666a6
1 changed files with 8 additions and 1 deletions
|
@ -141,10 +141,17 @@ static float _gradientToFloat(const SvgParser* svgParse, const char* str, SvgPar
|
||||||
static float _toOffset(const char* str)
|
static float _toOffset(const char* str)
|
||||||
{
|
{
|
||||||
char* end = nullptr;
|
char* end = nullptr;
|
||||||
|
auto strEnd = str + strlen(str);
|
||||||
|
|
||||||
float parsedValue = svgUtilStrtof(str, &end);
|
float parsedValue = svgUtilStrtof(str, &end);
|
||||||
|
|
||||||
if (strstr(str, "%")) parsedValue = parsedValue / 100.0;
|
end = _skipSpace(end, nullptr);
|
||||||
|
auto ptr = strstr(str, "%");
|
||||||
|
|
||||||
|
if (ptr) {
|
||||||
|
parsedValue = parsedValue / 100.0;
|
||||||
|
if (end != ptr || (end + 1) != strEnd) return 0;
|
||||||
|
} else if (end != strEnd) return 0;
|
||||||
|
|
||||||
return parsedValue;
|
return parsedValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue