Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public class DefaultModelValidator implements ModelValidator {

private static final String ILLEGAL_FS_CHARS = "\\/:\"<>|?*";

private static final String ILLEGAL_RELATIVE_PATH_CHARS = ":\"<>|?*";

private static final String ILLEGAL_VERSION_CHARS = ILLEGAL_FS_CHARS;

private static final String ILLEGAL_REPO_ID_CHARS = ILLEGAL_FS_CHARS;
Expand Down Expand Up @@ -153,6 +155,24 @@ public void validateRawModel(Model m, ModelBuildingRequest request, ModelProblem
} else if (request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0) {
Severity errOn30 = getSeverity(request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0);

Severity errOn31 = getSeverity(request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1);

// [MNG-8129] Validate that relativePath does not contain characters that are illegal in filesystem paths
if (parent != null
&& parent.getRelativePath() != null
&& !parent.getRelativePath().isEmpty()) {
validateBannedCharacters(
"parent.",
"relativePath",
problems,
errOn31,
Version.V20,
parent.getRelativePath(),
null,
parent,
ILLEGAL_RELATIVE_PATH_CHARS);
}

// [MNG-6074] Maven should produce an error if no model version has been set in a POM file used to build an
// effective model.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,16 @@ public void testDistributionManagementStatus() throws Exception {
assertTrue(result.getErrors().get(0).contains("distributionManagement.status"));
}

@Test
public void testBadParentRelativePath() throws Exception {
SimpleProblemCollector result = validateRaw("bad-parent-relativePath.xml");

assertViolations(result, 0, 0, 1);

assertContains(result.getWarnings().get(0), "parent.relativePath");
assertContains(result.getWarnings().get(0), "must not contain any of these characters");
}

@Test
public void testIncompleteParent() throws Exception {
SimpleProblemCollector result = validateRaw("incomplete-parent.xml");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
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.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>1</version>
<relativePath>org.apache:apache</relativePath>
</parent>

<artifactId>aid</artifactId>
<groupId>gid</groupId>
<version>0.1</version>
</project>
Loading