summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-07-31 03:01:50 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2018-07-31 11:02:38 +0200
commit524478f60e6eac991b9ef033a2030a9ea5aa5c36 (patch)
tree503d8fea0513f420ae93b5799ef7ca5686deba76
parent056809af50752adddb75b1b86b0d810dcc97b73e (diff)
parent1262e6dc979d0624307897980be27b8310fe34a0 (diff)
downloadqtsvg-524478f60e6eac991b9ef033a2030a9ea5aa5c36.tar.gz
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: .qmake.conf Change-Id: Ic41094e6744df3d84d76bcfe701092e137660f80
-rw-r--r--src/svg/qsvghandler.cpp11
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp26
2 files changed, 32 insertions, 5 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 1d83af2..10cb779 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -774,16 +774,17 @@ static QVector<qreal> parsePercentageList(const QChar *&str)
static QString idFromUrl(const QString &url)
{
QString::const_iterator itr = url.constBegin();
- while ((*itr).isSpace())
+ QString::const_iterator end = url.constEnd();
+ while (itr != end && (*itr).isSpace())
++itr;
- if ((*itr) == QLatin1Char('('))
+ if (itr != end && (*itr) == QLatin1Char('('))
++itr;
- while ((*itr).isSpace())
+ while (itr != end && (*itr).isSpace())
++itr;
- if ((*itr) == QLatin1Char('#'))
+ if (itr != end && (*itr) == QLatin1Char('#'))
++itr;
QString id;
- while ((*itr) != QLatin1Char(')')) {
+ while (itr != end && (*itr) != QLatin1Char(')')) {
id += *itr;
++itr;
}
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index 87d24c7..a8fc9de 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -54,6 +54,8 @@ private slots:
void getSetCheck();
void inexistentUrl();
void emptyUrl();
+ void invalidUrl_data();
+ void invalidUrl();
void testStrokeWidth();
void testMapViewBoxToTarget();
void testRenderElement();
@@ -132,6 +134,30 @@ void tst_QSvgRenderer::emptyUrl()
QVERIFY(renderer.isValid());
}
+void tst_QSvgRenderer::invalidUrl_data()
+{
+ QTest::addColumn<QByteArray>("svg");
+
+ QTest::newRow("00") << QByteArray("<svg><circle fill=\"url\" /></svg>");
+ QTest::newRow("01") << QByteArray("<svg><circle fill=\"url0\" /></svg>");
+ QTest::newRow("02") << QByteArray("<svg><circle fill=\"url(0\" /></svg>");
+ QTest::newRow("03") << QByteArray("<svg><circle fill=\"url (0\" /></svg>");
+ QTest::newRow("04") << QByteArray("<svg><circle fill=\"url ( 0\" /></svg>");
+ QTest::newRow("05") << QByteArray("<svg><circle fill=\"url#\" /></svg>");
+ QTest::newRow("06") << QByteArray("<svg><circle fill=\"url#(\" /></svg>");
+ QTest::newRow("07") << QByteArray("<svg><circle fill=\"url(#\" /></svg>");
+ QTest::newRow("08") << QByteArray("<svg><circle fill=\"url(# \" /></svg>");
+ QTest::newRow("09") << QByteArray("<svg><circle fill=\"url(# 0\" /></svg>");
+}
+
+void tst_QSvgRenderer::invalidUrl()
+{
+ QFETCH(QByteArray, svg);
+
+ QSvgRenderer renderer(svg);
+ QVERIFY(renderer.isValid());
+}
+
void tst_QSvgRenderer::testStrokeWidth()
{
qreal squareSize = 30.0;