Skip to content

Commit

Permalink
Avoid endless recursion
Browse files Browse the repository at this point in the history
* Normalize path before using it as key in a cache lookup (to avoid
/foo/../a to be different than /a)
* stop recursion if parent model is identical to child model

fixes #3809
  • Loading branch information
Bananeweizen authored and laeubi committed Sep 18, 2024
1 parent 2963a7a commit 7c0afd6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ protected Path getRealArtifactFile(Path polyglotArtifactFile) {
return polyglotArtifactFile;
}

protected synchronized ParentModel findParent(Path projectRoot, Map<String, ?> projectOptions) throws IOException {
protected synchronized ParentModel findParent(Path projectRootIn, Map<String, ?> projectOptions)
throws IOException {
var projectRoot = projectRootIn.normalize();
ParentModel cached = parentModelCache.get(projectRoot);
if (cached != null) {
return cached;
Expand Down Expand Up @@ -371,7 +373,7 @@ private boolean modelHasProperty(String property, Model model, Path projectRoot)
try {
ParentModel parent = findParent(projectRoot.getParent(), Map.of());
Model parentModel = parent.parentModel();
if (parentModel != null) {
if (parentModel != null && parentModel != model) {
return modelHasProperty(property, parentModel,
projectRoot.resolve(parent.parentReference().getRelativePath()));
}
Expand Down

0 comments on commit 7c0afd6

Please sign in to comment.