Bug 51646 - pathconvert - mapper using OS directory separator instead of dirsep
Summary: pathconvert - mapper using OS directory separator instead of dirsep
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.1
Hardware: PC Windows Server 2003
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-11 01:50 UTC by szetheli+apache
Modified: 2012-01-19 18:13 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description szetheli+apache 2011-08-11 01:50:15 UTC
It looks like pathcovert is using the OS directory separator for processing mapper even if a custom dirsep is specified.

I'm trying to write pathcovert statement that is OS agnostic, so I turn dirsep="/" since I don't want to deal with windows "\".  I need to do some manipulation on the path as well, turning the file names into properties, so I use mapper to strip the parts I don't need.

Example:
<pathconvert property="-service.fragments.properties" pathsep="=${line.separator}" dirsep="/"
  refid="-service.fragment.path" >
    <chainedmapper>
      <filtermapper>
	<!-- BUGBUG - even though dirsep=/, the filter sees \ on windows.  The below line is necessary to make windows/linux treat the path the same-->
	<replacestring from="\" to="/" />
	<replaceregex pattern=".*/([^/]*)" replace="\1"/>
      </filtermapper>
    </chainedmapper>
</pathconvert>

Expected:
If I comment out the replacestring statement, mapper should see the path elements as "a/b/c/file".

Actual:
with replacestring commented, replaceregex does not match, because its seeing a\b\c\file

Work around:
Adding replacestring statement in place of the dirsep attribute (yuck).
Comment 1 Jesse Glick 2012-01-19 14:31:58 UTC
Probably the dirsep processing is just happening after the mappers, in which case this is not a bug?
Comment 2 szetheli+apache 2012-01-19 18:13:27 UTC
I'd consider it at least "Undesirable behavior".  Just because that's the order the code currently evaluates things doesn't mean it's the order most desirable by the user. 

Given pathconvert is used to convert paths into different strings, not necessarily another path, it makes sense to me that dirsep should be applied before the filters look at it, otherwise dirsep can be pretty useless in pathcovert with filters.