Uploaded image for project: 'Maven Shared Components'
  1. Maven Shared Components
  2. MSHARED-19

getRelativePath fails on non-normalized inputs

    XMLWordPrintableJSON

Details

    • Patch

    Description

      The algo in AbstractSiteMojo.getRelativePath() assumes that its input paths are both normalized and produces wrong output if it gets something like "dir/../dir". Attached is a simple unit test and a fix for the method itself.

      FYI, non-normalized path are easily created by Maven if one has a non-Maven-like directory layout with
      project/
      project-parent/
      project-module-1/
      where simple string/path concatenation produces a path like "project/project-module-1/../project-parent" when referencing the parent POM from the module POM.

      Path/URL transformations like normalization/relativization/resolution are quite ubiquitous in Maven. Isn't there a nice util class around that prevents each and every plugin developer to reimplement those error-prone methods?

      Attachments

        1. normalized-paths.patch
          4 kB
          Benjamin Bentmann

        Activity

          People

            dennisl@apache.org Dennis Lundberg
            bentmann Benjamin Bentmann
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: