Maven Shared Components
  1. Maven Shared Components
  2. MSHARED-78

FilteringUtils escapeWindowsPath() doesn't work on Windows

    Details

    • Flags:
      Patch

      Description

      The method escapeWindowsPath() is replacing colon by backslash + colon.
      I.e.
      D:\temp
      is escaped as
      D\:
      temp

      But windows doesn't recognize that. If you try to open D\:
      temp on explorer, will not work.
      Even java.io.File is not able to handle that too. The attached test proves it.

      I'm not sure why this backslash was add to colon, but commenting line 44 of org.apache.maven.shared.filtering.FilteringUtils make the test work.

      1. filtering.patch
        0.9 kB
        velo
      2. FilteringUtilsTest.java
        0.8 kB
        velo

        Issue Links

          Activity

          Hide
          velo added a comment -

          At MRESOURCES-42 was suggested to escape colon too.

          I have no idea why, but this doesn't work on windows.

          Show
          velo added a comment - At MRESOURCES-42 was suggested to escape colon too. I have no idea why, but this doesn't work on windows.
          Hide
          Benjamin Bentmann added a comment -

          I believe the motivation for this escaping was the use case of filtering properties files, where backslash and colon have special meanings.

          Show
          Benjamin Bentmann added a comment - I believe the motivation for this escaping was the use case of filtering properties files, where backslash and colon have special meanings.
          Hide
          velo added a comment -

          I have XML and properties on my projects and it still working.

          I have no idea how important is to escape colon, but if this is truly required should be done only at .properties files.

          VELO

          Show
          velo added a comment - I have XML and properties on my projects and it still working. I have no idea how important is to escape colon, but if this is truly required should be done only at .properties files. VELO
          Hide
          Olivier Lamy (*$^¨%`£) added a comment -

          So what how can we fix that ?
          apply this only for files : *.properties ?
          Not really sure.

          Show
          Olivier Lamy (*$^¨%`£) added a comment - So what how can we fix that ? apply this only for files : *.properties ? Not really sure.
          Hide
          Paul Jackson added a comment -

          IMO, Filtering should not automatically add escape characters - it takes control away from a user. Better to never add escape characters and leave it to the user to add them as necessary.

          Show
          Paul Jackson added a comment - IMO, Filtering should not automatically add escape characters - it takes control away from a user. Better to never add escape characters and leave it to the user to add them as necessary.
          Hide
          Paul Jackson added a comment -

          The addition of backslashes in front of backslashes and colons is problematic.

          Show
          Paul Jackson added a comment - The addition of backslashes in front of backslashes and colons is problematic.
          Hide
          Olivier Lamy (*$^¨%`£) added a comment -

          Sure this should be optionnal.
          As it was introduced as a feature, IMHO this must enable by default and we must add a parameter to be able to disable this.

          Show
          Olivier Lamy (*$^¨%`£) added a comment - Sure this should be optionnal. As it was introduced as a feature, IMHO this must enable by default and we must add a parameter to be able to disable this.
          Hide
          Casey Butterworth added a comment -

          Unless there's a workaround that I'm not aware of, this defect is effectively rendering the 2.3 resources plugin unusable for any projects that uses resource filtering to directory locations (e.g. basedir) on windows, which I imagine is a large number of projects. MRESOURCES-81 is a good description of the problem.

          I've noticed that this is targeted at maven-filtering-1.0-beta-4, but i'm wondering if it should not be in the next release instead, and also be accompanied by a maven-release-plugin release?

          Show
          Casey Butterworth added a comment - Unless there's a workaround that I'm not aware of, this defect is effectively rendering the 2.3 resources plugin unusable for any projects that uses resource filtering to directory locations (e.g. basedir) on windows, which I imagine is a large number of projects. MRESOURCES-81 is a good description of the problem. I've noticed that this is targeted at maven-filtering-1.0-beta-4, but i'm wondering if it should not be in the next release instead, and also be accompanied by a maven-release-plugin release?
          Hide
          Jason van Zyl added a comment -

          The attached patch we've been using in Nexus for 3 months. Does anyone have a problem applying this?

          Show
          Jason van Zyl added a comment - The attached patch we've been using in Nexus for 3 months. Does anyone have a problem applying this?
          Hide
          Olivier Lamy (*$^¨%`£) added a comment -

          fixed in rev 749459

          Show
          Olivier Lamy (*$^¨%`£) added a comment - fixed in rev 749459
          Hide
          Anton Makeev added a comment -

          I reckon not only the windows paths should be escaped, but all the properties filtered.

          For example, if I have a property defined as <myValue>xxx\yyy:zzz<myValue> it will be read from the *.properties file incorrectly as well.

          Thanks,
          Anton Makeev

          Show
          Anton Makeev added a comment - I reckon not only the windows paths should be escaped, but all the properties filtered. For example, if I have a property defined as <myValue>xxx\yyy:zzz<myValue> it will be read from the *.properties file incorrectly as well. Thanks, Anton Makeev
          Hide
          Jayesh Lalwani added a comment -

          Where can I get maven-filtering-1.0-beta-4? Is there a SVN that I can checkout the code from?

          Show
          Jayesh Lalwani added a comment - Where can I get maven-filtering-1.0-beta-4? Is there a SVN that I can checkout the code from?
          Show
          Benjamin Bentmann added a comment - http://svn.apache.org/repos/asf/maven/shared/trunk/maven-filtering/

            People

            • Assignee:
              Olivier Lamy (*$^¨%`£)
              Reporter:
              velo
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development