You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Giovds (via GitHub)" <gi...@apache.org> on 2025/12/16 13:09:56 UTC
[PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Giovds opened a new pull request, #11568:
URL: https://github.com/apache/maven/pull/11568
Following this checklist to help us incorporate your
contribution quickly and easily:
- [x] Your pull request should address just one issue, without pulling in other changes.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Each commit in the pull request should have a meaningful subject line and body.
Note that commits might be squashed by a maintainer on merge.
- [x] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
This may not always be possible but is a best-practice.
- [x] Run `mvn verify` to make sure basic checks pass.
A more thorough check will be performed on your pull request automatically.
- [ ] You have run the [Core IT][core-its] successfully.
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [x] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
[core-its]: https://maven.apache.org/core-its/core-it-suite/
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #11568:
URL: https://github.com/apache/maven/pull/11568#issuecomment-3662253775
Build uses [Mimir](https://github.com/maveniverse/mimir) and _everything is cached_ except for Mimir itself (chicken or egg), but if Central spits HTTP 500 for Mimir, not much to do.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "Giovds (via GitHub)" <gi...@apache.org>.
Giovds commented on PR #11568:
URL: https://github.com/apache/maven/pull/11568#issuecomment-3664080979
Check. Thanks for rerunning, good to know it's a known issue
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #11568:
URL: https://github.com/apache/maven/pull/11568#discussion_r3369563723
##########
impl/maven-impl/src/main/java/org/apache/maven/api/services/model/UrlNormalizer.java:
##########
@@ -18,6 +18,17 @@
*/
package org.apache.maven.api.services.model;
+/**
+ * Simplifies URLs by removing parent directory references ("/../") and collapsing path segments.
+ * This performs purely string-based normalization without full URL parsing or validation.
+ *
+ * <p>The normalization process iteratively removes "/../" segments by eliminating the preceding path segment,
+ * effectively resolving relative path traversals.
+ *
+ * <p>This does not guarantee that the resulting URL is valid or reachable; it simply
Review Comment:
Nit: there is a trailing blank line before the closing `*/`. The existing method javadoc in this same file does not have one. Consider removing it for consistency:
```suggestion
* produces a more canonical representation of the input string.
*/
```
##########
impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultUrlNormalizerTest.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.impl;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class DefaultUrlNormalizerTest {
+
+ private final DefaultUrlNormalizer sut = new DefaultUrlNormalizer();
+
+ @Test
+ void normalizeShouldHandleNullAndEdgeCases() {
+ assertNull(sut.normalize(null));
+ assertEquals("", sut.normalize(""));
+ assertEquals("/", sut.normalize("/../"));
+ assertEquals("", sut.normalize("a/../"));
+ assertEquals("b", sut.normalize("a/../b"));
+ assertEquals("b/d", sut.normalize("a/../b/c/../d"));
+ assertEquals("b/c/d", sut.normalize("a/../b/c/d"));
+ assertEquals("b/c", sut.normalize("a/../b/c"));
+ assertEquals("b/", sut.normalize("a/../b/c/../"));
+ assertEquals("../", sut.normalize("../"));
+ }
+
+ @Test
+ void normalizeShouldPreserveHttpUrlTrailingSlash() {
+ assertEquals("https://example.com/path", sut.normalize("https://example.com/path"));
+ assertEquals("https://example.com/path/", sut.normalize("https://example.com/path/"));
+ }
+
+ @Test
+ void normalizeShouldCollapseParentReferencesInUrl() {
+ assertEquals("https://example.com/child", sut.normalize("https://example.com/parent/../child"));
+ assertEquals("https://example.com/child", sut.normalize("https://example.com/grand/parent/../../child"));
+ }
+
+ @Test
+ void normalizeHandlesDoubleSlashesAfterParent() {
+ assertEquals("https://example.com//child", sut.normalize("https://example.com/parent/..//child"));
+ assertEquals("https://example.com/child", sut.normalize("https://example.com/parent//../child"));
+ }
Review Comment:
Good idea testing with `file:////` and percent-encoded paths. You might also consider adding the `scm:hg:ssh://localhost//home/user` case from the compat tests, since SCM URLs are a common real-world input for this normalizer. Not a blocker.
##########
impl/maven-impl/src/test/java/org/apache/maven/impl/DefaultUrlNormalizerTest.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.impl;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class DefaultUrlNormalizerTest {
+
+ private final DefaultUrlNormalizer sut = new DefaultUrlNormalizer();
+
+ @Test
+ void normalizeShouldHandleNullAndEdgeCases() {
+ assertNull(sut.normalize(null));
+ assertEquals("", sut.normalize(""));
+ assertEquals("/", sut.normalize("/../"));
+ assertEquals("", sut.normalize("a/../"));
+ assertEquals("b", sut.normalize("a/../b"));
+ assertEquals("b/d", sut.normalize("a/../b/c/../d"));
+ assertEquals("b/c/d", sut.normalize("a/../b/c/d"));
+ assertEquals("b/c", sut.normalize("a/../b/c"));
+ assertEquals("b/", sut.normalize("a/../b/c/../"));
+ assertEquals("../", sut.normalize("../"));
+ }
Review Comment:
Minor: the `../` case at line 42 is testing a different behavioral category (leading parent references that cannot be resolved) compared to the null/empty/normal-traversal cases above it. Consider splitting this into its own test method for clarity, similar to how the compat test (`DefaultUrlNormalizerTest` under `compat/maven-model-builder`) has a dedicated `leadingParentDirectoryNotRemovedFromRelativeUriReference` test. Not a blocker, just a readability suggestion.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #11568:
URL: https://github.com/apache/maven/pull/11568#discussion_r2628190945
##########
impl/maven-impl/src/main/java/org/apache/maven/api/services/model/UrlNormalizer.java:
##########
@@ -18,6 +18,17 @@
*/
package org.apache.maven.api.services.model;
+/**
Review Comment:
Weird that we have an interface here. We don't really need it for anything, but that's tangential to this PR.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #11568:
URL: https://github.com/apache/maven/pull/11568#discussion_r2645570360
##########
impl/maven-impl/src/main/java/org/apache/maven/api/services/model/UrlNormalizer.java:
##########
@@ -18,6 +18,17 @@
*/
package org.apache.maven.api.services.model;
+/**
Review Comment:
since there is an interface, there is a possibility that a different implementation will do something different. Is this planned or intended? If not, we really should collapse this to a single class.
##########
impl/maven-impl/src/main/java/org/apache/maven/api/services/model/UrlNormalizer.java:
##########
@@ -18,6 +18,17 @@
*/
package org.apache.maven.api.services.model;
+/**
+ * Simplifies URLs by removing parent directory references ("/../") and collapsing path segments.
Review Comment:
I wonder if this comment belongs on the method rather than or in addition to the class so it will appear in IDE tooltips when I hover over an invocation?
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #11568:
URL: https://github.com/apache/maven/pull/11568#issuecomment-3662231850
Just the usual `Could not transfer artifact eu.maveniverse.maven.mimir.node:file:pom:0.10.6 from/to central (https://repo.maven.apache.org/maven2): HTTP Status: 500`
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "Giovds (via GitHub)" <gi...@apache.org>.
Giovds commented on PR #11568:
URL: https://github.com/apache/maven/pull/11568#issuecomment-3689247873
Is there anything I can do to help this PR further? I believe all comments have been resolved or discussed.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "Giovds (via GitHub)" <gi...@apache.org>.
Giovds commented on PR #11568:
URL: https://github.com/apache/maven/pull/11568#issuecomment-3662220683
@gnodet Highly unlikely the IT failed due to adding a comment and a unit test. Perhaps flaky or other issue?
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #11568:
URL: https://github.com/apache/maven/pull/11568#issuecomment-4730757652
Superseded by #12293, which rebases this work on current master (where `UrlNormalizer` was moved from `impl/maven-impl` to `api/maven-api-spi`).
Thank you for the contribution @rbrouwer!
_Fully automatic review from Claude Code_
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #11568:
URL: https://github.com/apache/maven/pull/11568#discussion_r2627495802
##########
impl/maven-impl/src/main/java/org/apache/maven/api/services/model/UrlNormalizer.java:
##########
@@ -18,6 +18,18 @@
*/
package org.apache.maven.api.services.model;
+/**
+ * Provide a service of {@link UrlNormalizer} that simplifies URL strings by removing parent directory
+ * references ("/../") and collapsing path segments. This implementation performs purely
Review Comment:
This is an interface, not an implementation
##########
impl/maven-impl/src/main/java/org/apache/maven/api/services/model/UrlNormalizer.java:
##########
@@ -18,6 +18,18 @@
*/
package org.apache.maven.api.services.model;
+/**
+ * Provide a service of {@link UrlNormalizer} that simplifies URL strings by removing parent directory
Review Comment:
This isn't really a "service" as that word is often used in software development these days. It's just an interface.
"Provide a service of {@link UrlNormalizer} that simplifies URL strings" --> Simplifies URLs
##########
impl/maven-impl/src/main/java/org/apache/maven/api/services/model/UrlNormalizer.java:
##########
@@ -18,6 +18,18 @@
*/
package org.apache.maven.api.services.model;
+/**
+ * Provide a service of {@link UrlNormalizer} that simplifies URL strings by removing parent directory
+ * references ("/../") and collapsing path segments. This implementation performs purely
+ * string-based normalization without full URL parsing or validation.
+ *
+ * <p>The normalization process iteratively removes "/../" segments by eliminating the preceding path segment,
+ * effectively resolving relative path traversals.
+ *
+ * <p>Note that this implementation does not guarantee that the resulting URL is valid or reachable; it simply
Review Comment:
Note that this implementation does not --> This does not
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "Giovds (via GitHub)" <gi...@apache.org>.
Giovds commented on code in PR #11568:
URL: https://github.com/apache/maven/pull/11568#discussion_r2628401110
##########
impl/maven-impl/src/main/java/org/apache/maven/api/services/model/UrlNormalizer.java:
##########
@@ -18,6 +18,17 @@
*/
package org.apache.maven.api.services.model;
+/**
Review Comment:
Personally I agree that having an interface with 1 implementation is not as pure as it can be, though this is indeed a topic that is beyond the scope of this PR.
I think the same discussion lives in #10328
If there is a consensus on what path we are taking, we can act accordingly for this (and perhaps more) classes.
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE-10329] Document behaviour of UrlNormalizer [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet closed pull request #11568: [ISSUE-10329] Document behaviour of UrlNormalizer
URL: https://github.com/apache/maven/pull/11568
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org