gnodet opened a new pull request, #14034: URL: https://github.com/apache/maven/pull/14034
Backport of #13882 to `maven-4.0.x`. The generated `MavenStaxReader` verified that child elements share the root element's namespace, but never validated the root namespace itself, so `<project xmlns="https://ff.com">` was accepted. When the existing (previously unused) `enforceNamespace` template parameter is set, `reader-stax.vm` now emits the list of accepted root namespaces, derived from the model's `XmlModelMetadata` for every model version between `minimalVersion` and the generated version. In strict mode, a root element in any other namespace is rejected; no namespace remains allowed. Only the POM reader sets `enforceNamespace`, so readers for settings, toolchains, metadata, plugin descriptors, lifecycles and extensions are unchanged. Lenient reads are unaffected, so POMs consumed from remote repositories keep working; project POMs fail with a "Malformed POM" error. **4.0.x adaptations:** - Removed `http://maven.apache.org/POM/4.2.0` from the accepted-namespaces test (not a valid POM namespace on this branch) - Added missing `ModelBuilderException` import and `assertThrows` static import to `DefaultModelBuilderTest` (already present on master's base, absent on `maven-4.0.x`) Cherry-picked from 68efb356909488888a672fd1808abf54ecdebda2. <!-- maven-backport-bot --> -- 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]
