summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSemih Yavuz <semih.yavuz@qt.io>2023-11-07 15:02:24 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-11-07 18:57:58 +0000
commit6aae5b1bf13bb624293d1d3c9b2f79377bb13e29 (patch)
tree5aaa81774e12939093c585763fcff2fc1ac0c7d4
parentd867e59f1ff994803d95cc9c144f20b5996e6e08 (diff)
qtscxml: Error out when no script content given
Standard says https://www.w3.org/TR/scxml/#script that there should be either src or some content in the script tag. Compiling should fail with non-conformant .scxml files. Adjust the number of the errors in a few test because of newly added error. Pick-to: 6.5 5.15 Fixes: QTBUG-118050 Change-Id: Ib72f7cca53e427a5a83a6aaa3a8a197818e8693f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 445a52209db72287f7bd57f01fbb54b102bb042b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/scxml/qscxmlcompiler.cpp3
-rw-r--r--tests/auto/parser/CMakeLists.txt2
-rw-r--r--tests/auto/parser/data/badInitial.scxml.errors1
-rw-r--r--tests/auto/parser/data/commentInScript.scxml.errors1
-rw-r--r--tests/auto/parser/data/emptyScript.scxml12
-rw-r--r--tests/auto/parser/data/emptyScript.scxml.errors1
6 files changed, 20 insertions, 0 deletions
diff --git a/src/scxml/qscxmlcompiler.cpp b/src/scxml/qscxmlcompiler.cpp
index ffd0ab6..eaf7171 100644
--- a/src/scxml/qscxmlcompiler.cpp
+++ b/src/scxml/qscxmlcompiler.cpp
@@ -2048,6 +2048,9 @@ bool QScxmlCompilerPrivate::postReadElementScript()
scriptI->content = QString::fromUtf8(data);
}
}
+ } else {
+ addError(scriptI->xmlLocation,
+ QStringLiteral("neither src nor any content has been given in the script tag"));
}
return flushInstruction();
}
diff --git a/tests/auto/parser/CMakeLists.txt b/tests/auto/parser/CMakeLists.txt
index d441703..0e05699 100644
--- a/tests/auto/parser/CMakeLists.txt
+++ b/tests/auto/parser/CMakeLists.txt
@@ -97,6 +97,8 @@ set(tst_parser_resource_files
"data/syntaxErrors9.scxml.errors"
"data/test1.scxml"
"data/test1.scxml.errors"
+ "data/emptyScript.scxml"
+ "data/emptyScript.scxml.errors"
)
qt_internal_add_resource(tst_scxml_parser "tst_parser"
diff --git a/tests/auto/parser/data/badInitial.scxml.errors b/tests/auto/parser/data/badInitial.scxml.errors
index fa2eba9..fc0b240 100644
--- a/tests/auto/parser/data/badInitial.scxml.errors
+++ b/tests/auto/parser/data/badInitial.scxml.errors
@@ -1,2 +1,3 @@
:/tst_parser/data/badInitial.scxml:8:13: error: Unexpected element initial
+:/tst_parser/data/badInitial.scxml:7:12: error: neither src nor any content has been given in the script tag
:/tst_parser/data/badInitial.scxml:12:8: error: Error parsing SCXML file: Opening and ending tag mismatch.
diff --git a/tests/auto/parser/data/commentInScript.scxml.errors b/tests/auto/parser/data/commentInScript.scxml.errors
index d12133f..211becb 100644
--- a/tests/auto/parser/data/commentInScript.scxml.errors
+++ b/tests/auto/parser/data/commentInScript.scxml.errors
@@ -1 +1,2 @@
+:/tst_parser/data/commentInScript.scxml:6:12: error: neither src nor any content has been given in the script tag
:/tst_parser/data/commentInScript.scxml:6:0: error: Error parsing SCXML file: Premature end of document.
diff --git a/tests/auto/parser/data/emptyScript.scxml b/tests/auto/parser/data/emptyScript.scxml
new file mode 100644
index 0000000..48dd53b
--- /dev/null
+++ b/tests/auto/parser/data/emptyScript.scxml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" binding="early" xmlns:qt="http://www.qt.io/2015/02/scxml-ext" name="StateChart" qt:editorversion="11.0.1">
+ <state id="Initial">
+ <transition type="external" event="crash" target="Final_1">
+ <script>
+ </script>
+ </transition>
+ </state>
+ <final id="Final_1">
+ </final>
+</scxml>
+
diff --git a/tests/auto/parser/data/emptyScript.scxml.errors b/tests/auto/parser/data/emptyScript.scxml.errors
new file mode 100644
index 0000000..bbd55a4
--- /dev/null
+++ b/tests/auto/parser/data/emptyScript.scxml.errors
@@ -0,0 +1 @@
+:/tst_parser/data/emptyScript.scxml:5:20: error: neither src nor any content has been given in the script tag \ No newline at end of file