diff --git a/WHATSNEW b/WHATSNEW index b14b82faf..9dc6d9a71 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -216,6 +216,8 @@ Fixed bugs: * ftp chmod failed when the remote system was UNIX and local system Windows Bugzilla Report 21865. +* replace would change \r\n into \r\r\n under Windows. + Other changes: -------------- * Six new Clearcase tasks added. diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java index 29122a0e9..8ffe2ec64 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Replace.java +++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java @@ -423,9 +423,13 @@ public class Replace extends MatchingTask { // line separators in values and tokens are "\n" // in order to compare with the file contents, replace them // as needed - String val = stringReplace(value.getText(), "\n", + String val = stringReplace(value.getText(), "\r\n", + "\n", false); + val = stringReplace(val, "\n", StringUtils.LINE_SEP, false); - String tok = stringReplace(token.getText(), "\n", + String tok = stringReplace(token.getText(), "\r\n", + "\n", false); + tok = stringReplace(tok, "\n", StringUtils.LINE_SEP, false); // for each found token, replace with value