You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Accept any official POM namespace version (e.g., 4.0.0, 4.1.0)
282
-
if (!rootNs.startsWith("http://maven.apache.org/POM/")) {
283
-
throw new XMLStreamException(
284
-
"Unrecognized POM namespace '" + rootNs
285
-
+ "'. Expected something like 'http://maven.apache.org/POM/4.x.y' or no namespace.",
286
-
parser.getLocation(), null);
287
-
}
288
-
} else if ("metadata".equals("${rootTag}")) {
289
-
// Accept official METADATA namespaces (e.g., 1.1.0)
290
-
if (!rootNs.startsWith("http://maven.apache.org/METADATA/")) {
291
-
throw new XMLStreamException(
292
-
"Unrecognized METADATA namespace '" + rootNs
293
-
+ "'. Expected something like 'http://maven.apache.org/METADATA/1.x.y' or no namespace.",
294
-
parser.getLocation(), null);
295
-
}
296
-
} else {
297
-
// Other models: do not enforce at root level.
298
-
}
276
+
// Root namespace policy:
277
+
// - POM ('project'): allow no namespace or any http://maven.apache.org/POM/<version>
278
+
// - METADATA ('metadata'): allow no namespace or any http://maven.apache.org/METADATA/<version>
279
+
// - Other readers: do not enforce root namespace here (child checks still apply when strict)
280
+
if (strict) {
281
+
final String rootNs = parser.getNamespaceURI();
282
+
final boolean hasNs = rootNs != null && !rootNs.isEmpty();
283
+
284
+
if ("project".equals("${rootTag}")) {
285
+
if (hasNs && !rootNs.startsWith("http://maven.apache.org/POM/")) {
286
+
throw new XMLStreamException("Unrecognized POM namespace '" + rootNs + "'. Expected something like 'http://maven.apache.org/POM/4.x.y' or no namespace.",
287
+
parser.getLocation(), null);
288
+
}
289
+
} else if ("metadata".equals("${rootTag}")) {
290
+
if (hasNs && !rootNs.startsWith("http://maven.apache.org/METADATA/")) {
291
+
throw new XMLStreamException("Unrecognized METADATA namespace '" + rootNs + "'. Expected something like 'http://maven.apache.org/METADATA/1.x.y' or no namespace.",
292
+
parser.getLocation(), null);
293
+
}
294
+
} else {
295
+
// Other generated models (settings, lifecycles, extensions, plugin, toolchains, …):
0 commit comments