diff --git a/WHATSNEW b/WHATSNEW
index dcbda4b6d..63d9dc505 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -21,6 +21,8 @@ Fixed bugs:
* macrodef @@ escaping was broken. Bugzilla Report 27069.
+* replacestring tokenfilter only replaced the first occurrence.
+
Other changes:
--------------
diff --git a/src/etc/testcases/filters/tokenfilter.xml b/src/etc/testcases/filters/tokenfilter.xml
index ddfa57eba..86f5b9250 100644
--- a/src/etc/testcases/filters/tokenfilter.xml
+++ b/src/etc/testcases/filters/tokenfilter.xml
@@ -67,6 +67,15 @@
+
+
+ foo foo foo
+
+
+
+
+
+
This is a number
@@ -134,6 +143,17 @@
+
+
+ foo foo foo
+
+
+
+
+
+
+
+
this is a line contains foo
diff --git a/src/main/org/apache/tools/ant/filters/TokenFilter.java b/src/main/org/apache/tools/ant/filters/TokenFilter.java
index a1f234b10..f195ca62f 100644
--- a/src/main/org/apache/tools/ant/filters/TokenFilter.java
+++ b/src/main/org/apache/tools/ant/filters/TokenFilter.java
@@ -527,7 +527,7 @@ public class TokenFilter extends BaseFilterReader
// search again
start = found + from.length();
- found = line.indexOf(line, start);
+ found = line.indexOf(from, start);
}
// write the remaining characters
diff --git a/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java b/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java
index d3607eea8..e35e3f871 100644
--- a/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java
+++ b/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java
@@ -82,6 +82,10 @@ public class TokenFilterTest extends BuildFileTest {
"this is the moon");
}
+ public void testReplaceStrings() throws IOException {
+ expectLogContaining("replacestrings", "bar bar bar");
+ }
+
public void testContainsString() throws IOException {
String contents = getFileString(
"containsstring", "result/containsstring");
@@ -139,6 +143,10 @@ public class TokenFilterTest extends BuildFileTest {
assertStringContains(contents, "This is the moon");
}
+ public void testFilterReplaceStrings() throws IOException {
+ expectLogContaining("filterreplacestrings", "bar bar bar");
+ }
+
public void testContainsRegex() throws IOException {
if (! hasRegex("testContainsRegex"))
return;