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

FilteringUtils.escapeWindowsPath doesn't handle paths that leave out the drive letter.

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: maven-filtering-1.0-beta-3
    • Fix Version/s: None
    • Component/s: maven-filtering
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      2

      Description

      FilteringUtils.escapeWindowsPath requires a drive letter to be present in the path, or at least the string

      ":\\"

      to be present in order to trigger escaping the value as a windows path.

      In cases where the path is an absolute reference to a file on the current drive (no drive letter is included), or when the path starts with an unresolved expression (in cases where n+1 level interpolation will eventually resolve the expression), escaping doesn't happen at all.

        Issue Links

          Activity

          John Casey made changes -
          Field Original Value New Value
          Description FilteringUtils.escapeWindowsPath requires a drive letter to be present in the path, or at least the string ":\\" to be present in order to trigger escaping the value as a windows path.

          In cases where the path is an absolute reference to a file on the current drive (no drive letter is included), or when the path starts with an unresolved expression (in cases where n+1 level interpolation will eventually resolve the expression), escaping doesn't happen at all.
          FilteringUtils.escapeWindowsPath requires a drive letter to be present in the path, or at least the string <pre>":\\"</pre> to be present in order to trigger escaping the value as a windows path.

          In cases where the path is an absolute reference to a file on the current drive (no drive letter is included), or when the path starts with an unresolved expression (in cases where n+1 level interpolation will eventually resolve the expression), escaping doesn't happen at all.
          John Casey made changes -
          Description FilteringUtils.escapeWindowsPath requires a drive letter to be present in the path, or at least the string <pre>":\\"</pre> to be present in order to trigger escaping the value as a windows path.

          In cases where the path is an absolute reference to a file on the current drive (no drive letter is included), or when the path starts with an unresolved expression (in cases where n+1 level interpolation will eventually resolve the expression), escaping doesn't happen at all.
          FilteringUtils.escapeWindowsPath requires a drive letter to be present in the path, or at least the string {noformat}":\\"{noformat} to be present in order to trigger escaping the value as a windows path.

          In cases where the path is an absolute reference to a file on the current drive (no drive letter is included), or when the path starts with an unresolved expression (in cases where n+1 level interpolation will eventually resolve the expression), escaping doesn't happen at all.
          Hide
          John Casey added a comment -

          a patch containing the unit tests for three use cases: complete absolute windows path, windows path absolute from current drive, and windows path starting with an unresolved expression. Also contains a simplistic solution to assume anything with a backslash is a windows path. I'm fairly certain we'll want something more fine-grained than this, but not sure how to address it yet.

          Show
          John Casey added a comment - a patch containing the unit tests for three use cases: complete absolute windows path, windows path absolute from current drive, and windows path starting with an unresolved expression. Also contains a simplistic solution to assume anything with a backslash is a windows path. I'm fairly certain we'll want something more fine-grained than this, but not sure how to address it yet.
          John Casey made changes -
          John Casey made changes -
          Fix Version/s maven-filtering-1.0-beta-3 [ 14631 ]
          Hide
          John Casey added a comment -

          pushing this issue, as I'm not sure how to fix this for relative windows paths without messing up cases where the value is not meant to be a relative windows path, but happens to contain a backslash...

          Show
          John Casey added a comment - pushing this issue, as I'm not sure how to fix this for relative windows paths without messing up cases where the value is not meant to be a relative windows path, but happens to contain a backslash...
          John Casey made changes -
          Fix Version/s maven-filtering-1.0-beta-3 [ 14631 ]
          Fix Version/s maven-filtering-1.0-beta-4 [ 14861 ]
          Hide
          Kathy Hale added a comment -

          It's funny you say that because I have the opposite problem. I'm using this bug to disable the auto trigger because I couldn't find any way to disable it. So if I need a path to remain unescaped (single backslashes, not doubled), I've been breaking up the filter param like "$

          {drive}${path}", such that ${drive}

          is "C:" and {{$

          {path}

          }} is "\path."

          Show
          Kathy Hale added a comment - It's funny you say that because I have the opposite problem. I'm using this bug to disable the auto trigger because I couldn't find any way to disable it. So if I need a path to remain unescaped (single backslashes, not doubled), I've been breaking up the filter param like "$ {drive}${path}", such that ${drive} is " C: " and {{$ {path} }} is " \path ."
          Benjamin Bentmann made changes -
          Fix Version/s maven-filtering-1.0-beta-4 [ 14861 ]
          Dennis Lundberg made changes -
          Link This issue is related to MSHARED-179 [ MSHARED-179 ]
          Hide
          Dennis Lundberg added a comment -

          In r1055372 I committed the test case submitted by John Casey, but with the two failing tests commented out.

          Show
          Dennis Lundberg added a comment - In r1055372 I committed the test case submitted by John Casey, but with the two failing tests commented out.
          Hide
          Robert Scholte added a comment -

          Auto windows escaping really depends on the final reader of that file. I've seen reader where Windows files must be escaped, but also where they should not.

          # You are reading the ".properties" entry.
          ! The exclamation mark can also mark text as comments.
          # The key and element characters #, !, =, and : are written with
          # a preceding backslash to ensure that they are properly loaded.
          website = http\://en.wikipedia.org/
          language = English
          # The backslash below tells the application to continue reading
          # the value onto the next line.
          message = Welcome to \
                    Wikipedia\!
          # Add spaces to the key
          key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
          # Unicode
          tab : \u0009
          

          Here is just an example of other values where certain characters should be escaped. Not the input value, but the output file controls the way of escaping.
          When talking about XML it even gets more complicated, since escaping isn't done with a prefix but with a replacement.

          So I think we need to introduce an improved DelimiterSpecification, something for a 2.0 version of this component.

          Show
          Robert Scholte added a comment - Auto windows escaping really depends on the final reader of that file. I've seen reader where Windows files must be escaped, but also where they should not. http://en.wikipedia.org/wiki/.properties # You are reading the ".properties" entry. ! The exclamation mark can also mark text as comments. # The key and element characters #, !, =, and : are written with # a preceding backslash to ensure that they are properly loaded. website = http\://en.wikipedia.org/ language = English # The backslash below tells the application to continue reading # the value onto the next line. message = Welcome to \ Wikipedia\! # Add spaces to the key key\ with\ spaces = This is the value that could be looked up with the key "key with spaces". # Unicode tab : \u0009 Here is just an example of other values where certain characters should be escaped. Not the input value, but the output file controls the way of escaping. When talking about XML it even gets more complicated, since escaping isn't done with a prefix but with a replacement. So I think we need to introduce an improved DelimiterSpecification , something for a 2.0 version of this component.

            People

            • Assignee:
              Unassigned
              Reporter:
              John Casey
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: