summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Baijot <vincentbaijot@gmail.com>2021-04-18 18:23:46 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-20 02:48:52 +0000
commitff9a091241370c266064c1585e56f4fb5d2436c8 (patch)
tree4b01b5d7ac52348b06ad52c15e8c5b3474bb7731
parentc701e6bb38bbab9520b43297e8bc603f09227f44 (diff)
Correct prefix reported for end element in QXmlStreamReader
Before this change, QXmlStreamReader prefix value was always an empty string for EndElement when the documentation state : "Returns the prefix of a StartElement or EndElement." The error was a missing update of the prefix value when parsing EndElement. I updated the tests data which were also wrong because no prefix were reported even for </a:foo>. No new test is necessary, I think, the test data already cover the cases of EndElement with a prefix and without one (unchanged here). Fixes: QTBUG-86847 Change-Id: I0ad38b9741d760f1ce688a36f969ec14e20a928c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 366bdcde97962cf5804c519e9b605eddb543a592) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/serialization/qxmlstream.g2
-rw-r--r--src/corelib/serialization/qxmlstreamparser_p.h2
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/data/019.ref2
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/data/024.ref4
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/data/039.ref2
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/data/041.ref2
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/data/1.ref2
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/data/2.ref2
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/data/21.ref10
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/data/namespaceCDATA.ref2
10 files changed, 17 insertions, 13 deletions
diff --git a/src/corelib/serialization/qxmlstream.g b/src/corelib/serialization/qxmlstream.g
index b6417b080c..0051c6255b 100644
--- a/src/corelib/serialization/qxmlstream.g
+++ b/src/corelib/serialization/qxmlstream.g
@@ -237,6 +237,7 @@ bool QXmlStreamReaderPrivate::parse()
setType(QXmlStreamReader::EndElement);
Tag tag = tagStack_pop();
namespaceUri = tag.namespaceDeclaration.namespaceUri;
+ prefix = tag.namespaceDeclaration.prefix;
name = tag.name;
qualifiedName = tag.qualifiedName;
isEmptyElement = false;
@@ -1300,6 +1301,7 @@ etag ::= LANGLE SLASH qname space_opt RANGLE;
namespaceUri = tag.namespaceDeclaration.namespaceUri;
name = tag.name;
qualifiedName = tag.qualifiedName;
+ prefix = tag.namespaceDeclaration.prefix;
if (qualifiedName != symName(3))
raiseWellFormedError(QXmlStream::tr("Opening and ending tag mismatch."));
} break;
diff --git a/src/corelib/serialization/qxmlstreamparser_p.h b/src/corelib/serialization/qxmlstreamparser_p.h
index a5d8312390..d568f9d024 100644
--- a/src/corelib/serialization/qxmlstreamparser_p.h
+++ b/src/corelib/serialization/qxmlstreamparser_p.h
@@ -92,6 +92,7 @@ bool QXmlStreamReaderPrivate::parse()
setType(QXmlStreamReader::EndElement);
Tag tag = tagStack_pop();
namespaceUri = tag.namespaceDeclaration.namespaceUri;
+ prefix = tag.namespaceDeclaration.prefix;
name = tag.name;
qualifiedName = tag.qualifiedName;
isEmptyElement = false;
@@ -843,6 +844,7 @@ bool QXmlStreamReaderPrivate::parse()
Tag tag = tagStack_pop();
namespaceUri = tag.namespaceDeclaration.namespaceUri;
+ prefix = tag.namespaceDeclaration.prefix;
name = tag.name;
qualifiedName = tag.qualifiedName;
if (qualifiedName != symName(3))
diff --git a/tests/auto/corelib/serialization/qxmlstream/data/019.ref b/tests/auto/corelib/serialization/qxmlstream/data/019.ref
index 314efb2b04..9ae28f42e5 100644
--- a/tests/auto/corelib/serialization/qxmlstream/data/019.ref
+++ b/tests/auto/corelib/serialization/qxmlstream/data/019.ref
@@ -3,5 +3,5 @@ Comment( text=" Simple legal case: prefixed element " )
StartElement( name="foo" namespaceUri="http://example.org/namespace" qualifiedName="a:foo" prefix="a"
NamespaceDeclaration( prefix="a" namespaceUri="http://example.org/namespace" )
)
-EndElement( name="foo" namespaceUri="http://example.org/namespace" qualifiedName="a:foo" )
+EndElement( name="foo" namespaceUri="http://example.org/namespace" qualifiedName="a:foo" prefix="a" )
EndDocument( )
diff --git a/tests/auto/corelib/serialization/qxmlstream/data/024.ref b/tests/auto/corelib/serialization/qxmlstream/data/024.ref
index 83c3ac5315..43cf2b1faf 100644
--- a/tests/auto/corelib/serialization/qxmlstream/data/024.ref
+++ b/tests/auto/corelib/serialization/qxmlstream/data/024.ref
@@ -8,8 +8,8 @@ Characters( whitespace text="
StartElement( name="foo" namespaceUri="http://example.org/other-namespace" qualifiedName="a:foo" prefix="a"
NamespaceDeclaration( prefix="a" namespaceUri="http://example.org/other-namespace" )
)
-EndElement( name="foo" namespaceUri="http://example.org/other-namespace" qualifiedName="a:foo" )
+EndElement( name="foo" namespaceUri="http://example.org/other-namespace" qualifiedName="a:foo" prefix="a" )
Characters( whitespace text="
" )
-EndElement( name="foo" namespaceUri="http://example.org/namespace" qualifiedName="a:foo" )
+EndElement( name="foo" namespaceUri="http://example.org/namespace" qualifiedName="a:foo" prefix="a" )
EndDocument( )
diff --git a/tests/auto/corelib/serialization/qxmlstream/data/039.ref b/tests/auto/corelib/serialization/qxmlstream/data/039.ref
index 63ee6b4def..f7413e5436 100644
--- a/tests/auto/corelib/serialization/qxmlstream/data/039.ref
+++ b/tests/auto/corelib/serialization/qxmlstream/data/039.ref
@@ -16,7 +16,7 @@ StartElement( name="bar" namespaceUri="http://example.org/~kipper" qualifiedName
Attribute( name="attr" qualifiedName="attr" value="2" )
)
-EndElement( name="bar" namespaceUri="http://example.org/~kipper" qualifiedName="b:bar" )
+EndElement( name="bar" namespaceUri="http://example.org/~kipper" qualifiedName="b:bar" prefix="b" )
Characters( whitespace text="
" )
diff --git a/tests/auto/corelib/serialization/qxmlstream/data/041.ref b/tests/auto/corelib/serialization/qxmlstream/data/041.ref
index 3e7ca64208..50328feb4a 100644
--- a/tests/auto/corelib/serialization/qxmlstream/data/041.ref
+++ b/tests/auto/corelib/serialization/qxmlstream/data/041.ref
@@ -12,7 +12,7 @@ StartElement( name="bar" namespaceUri="http://example.org/~wilbur" qualifiedName
Attribute( name="attr" qualifiedName="attr" value="2" )
)
-EndElement( name="bar" namespaceUri="http://example.org/~wilbur" qualifiedName="a:bar" )
+EndElement( name="bar" namespaceUri="http://example.org/~wilbur" qualifiedName="a:bar" prefix="a" )
Characters( whitespace text="
" )
diff --git a/tests/auto/corelib/serialization/qxmlstream/data/1.ref b/tests/auto/corelib/serialization/qxmlstream/data/1.ref
index 0288cf0e11..41a9febd8e 100644
--- a/tests/auto/corelib/serialization/qxmlstream/data/1.ref
+++ b/tests/auto/corelib/serialization/qxmlstream/data/1.ref
@@ -4,5 +4,5 @@ StartElement( name="doc" namespaceUri="namespaceUri" qualifiedName="ns:doc" pref
NamespaceDeclaration( prefix="ns" namespaceUri="namespaceUri" )
)
-EndElement( name="doc" namespaceUri="namespaceUri" qualifiedName="ns:doc" )
+EndElement( name="doc" namespaceUri="namespaceUri" qualifiedName="ns:doc" prefix="ns" )
EndDocument( )
diff --git a/tests/auto/corelib/serialization/qxmlstream/data/2.ref b/tests/auto/corelib/serialization/qxmlstream/data/2.ref
index 95d68efbd6..2fad9844ce 100644
--- a/tests/auto/corelib/serialization/qxmlstream/data/2.ref
+++ b/tests/auto/corelib/serialization/qxmlstream/data/2.ref
@@ -5,5 +5,5 @@ StartElement( name="doc" namespaceUri="namespaceUri" qualifiedName="ns:doc" pref
NamespaceDeclaration( prefix="ns" namespaceUri="namespaceUri" )
)
Characters( text="The world goes round and round" )
-EndElement( name="doc" namespaceUri="namespaceUri" qualifiedName="ns:doc" )
+EndElement( name="doc" namespaceUri="namespaceUri" qualifiedName="ns:doc" prefix="ns" )
EndDocument( )
diff --git a/tests/auto/corelib/serialization/qxmlstream/data/21.ref b/tests/auto/corelib/serialization/qxmlstream/data/21.ref
index 1098c6800f..d0e4982eec 100644
--- a/tests/auto/corelib/serialization/qxmlstream/data/21.ref
+++ b/tests/auto/corelib/serialization/qxmlstream/data/21.ref
@@ -33,10 +33,10 @@ Characters( whitespace text="
" )
StartElement( name="title" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:title" prefix="html" )
Characters( text="test file" )
-EndElement( name="title" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:title" )
+EndElement( name="title" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:title" prefix="html" )
Characters( whitespace text="
" )
-EndElement( name="head" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:head" )
+EndElement( name="head" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:head" prefix="html" )
Characters( whitespace text="
" )
StartElement( name="body" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:body" prefix="html" )
@@ -46,11 +46,11 @@ StartElement( name="p" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName
Attribute( name="class" qualifiedName="class" value="visible:false" )
)
Characters( text="bar" )
-EndElement( name="p" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:p" )
+EndElement( name="p" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:p" prefix="html" )
Characters( whitespace text="
" )
-EndElement( name="body" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:body" )
+EndElement( name="body" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:body" prefix="html" )
Characters( whitespace text="
" )
-EndElement( name="html" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:html" )
+EndElement( name="html" namespaceUri="http://www.w3.org/1999/xhtml" qualifiedName="html:html" prefix="html" )
EndDocument( )
diff --git a/tests/auto/corelib/serialization/qxmlstream/data/namespaceCDATA.ref b/tests/auto/corelib/serialization/qxmlstream/data/namespaceCDATA.ref
index 132875f4bb..84538b0230 100644
--- a/tests/auto/corelib/serialization/qxmlstream/data/namespaceCDATA.ref
+++ b/tests/auto/corelib/serialization/qxmlstream/data/namespaceCDATA.ref
@@ -15,7 +15,7 @@ Characters( whitespace text="
StartElement( name="bar" namespaceUri="http://qt-project.org" qualifiedName="pre:bar" prefix="pre"
NamespaceDeclaration( prefix="pre" namespaceUri="http://qt-project.org" )
)
-EndElement( name="bar" namespaceUri="http://qt-project.org" qualifiedName="pre:bar" )
+EndElement( name="bar" namespaceUri="http://qt-project.org" qualifiedName="pre:bar" prefix="pre" )
Characters( whitespace text="
" )
EndElement( name="body" qualifiedName="body" )