gnodet commented on code in PR #11185:
URL: https://github.com/apache/maven/pull/11185#discussion_r2413533081
##########
src/mdo/reader-stax.vm:
##########
@@ -263,32 +263,58 @@ public class ${className} {
#if ( $needXmlContext )
Deque<Object> context = new ArrayDeque<>();
#end
- $rootUcapName $rootLcapName = null;
- int eventType = parser.getEventType();
- boolean parsed = false;
- while (eventType != XMLStreamReader.END_DOCUMENT) {
- if (eventType == XMLStreamReader.START_ELEMENT) {
- if (strict && ! "${rootTag}".equals(parser.getLocalName())) {
- throw new XMLStreamException("Expected root element
'${rootTag}' but found '" + parser.getName() + "'", parser.getLocation(), null);
- } else if (parsed) {
- // fallback, already expected a XMLStreamException due to
invalid XML
- throw new XMLStreamException("Duplicated tag:
'${rootTag}'", parser.getLocation(), null);
- }
-#if ( $locationTracking )
- $rootLcapName = parse${rootUcapName}(parser, strict,
parser.getNamespaceURI(), inputSrc);
-#elseif ( $needXmlContext )
- $rootLcapName = parse${rootUcapName}(parser, strict,
parser.getNamespaceURI(), context);
-#else
- $rootLcapName = parse${rootUcapName}(parser, strict,
parser.getNamespaceURI());
-#end
- parsed = true;
+$rootUcapName $rootLcapName = null;
+ int eventType = parser.getEventType();
+ boolean parsed = false;
+ while (eventType != XMLStreamReader.END_DOCUMENT) {
+ if (eventType == XMLStreamReader.START_ELEMENT) {
+ if (strict && ! "${rootTag}".equals(parser.getLocalName())) {
+ throw new XMLStreamException("Expected root element '${rootTag}' but found
'" + parser.getName() + "'", parser.getLocation(), null);
+ } else if (parsed) {
+ throw new XMLStreamException("Duplicated tag: '${rootTag}'",
parser.getLocation(), null);
+ }
+ // Root namespace policy:
+ // - POM ('project'): allow no namespace or any
http://maven.apache.org/POM/<version>
+ // - METADATA ('metadata'): allow no namespace or any
http://maven.apache.org/METADATA/<version>
+ // - Other readers: do not enforce root namespace here (child checks
still apply when strict)
+ if (strict) {
+ final String rootNs = parser.getNamespaceURI();
+ final boolean hasNs = rootNs != null && !rootNs.isEmpty();
+
+ if ("project".equals("${rootTag}")) {
+ if (hasNs && !rootNs.startsWith("http://maven.apache.org/POM/")) {
Review Comment:
See https://github.com/codehaus-plexus/modello/pull/522
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]