summaryrefslogtreecommitdiffstats
path: root/src/svg/qsvghandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/svg/qsvghandler.cpp')
-rw-r--r--src/svg/qsvghandler.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index e2c3d92..35b8595 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -810,24 +810,27 @@ static bool resolveColor(const QStringRef &colorStr, QColor &color, QSvgHandler
case 'r':
{
- // starts with "rgb("
- if (colorStrTr == QLatin1String("rgb(")) {
+ // starts with "rgb(", ends with ")" and consists of at least 7 characters "rgb(,,)"
+ if (colorStrTr.length() >= 7 && colorStrTr.at(colorStrTr.length() - 1) == QLatin1Char(')')
+ && QStringRef(colorStrTr.string(), colorStrTr.position(), 4) == QLatin1String("rgb(")) {
const QChar *s = colorStrTr.constData() + 4;
QVector<qreal> compo = parseNumbersList(s);
//1 means that it failed after reaching non-parsable
//character which is going to be "%"
if (compo.size() == 1) {
- const QChar *s = colorStrTr.constData() + 4;
+ s = colorStrTr.constData() + 4;
compo = parsePercentageList(s);
- compo[0] *= (qreal)2.55;
- compo[1] *= (qreal)2.55;
- compo[2] *= (qreal)2.55;
+ for (int i = 0; i < compo.size(); ++i)
+ compo[i] *= (qreal)2.55;
}
- color = QColor(int(compo[0]),
- int(compo[1]),
- int(compo[2]));
- return true;
+ if (compo.size() == 3) {
+ color = QColor(int(compo[0]),
+ int(compo[1]),
+ int(compo[2]));
+ return true;
+ }
+ return false;
}
}
break;