Fix bug in SafeHtml.replaceAll and bump to 1.3.4
Joining an empty list produces the pattern (), which matches an infinite number of times, which is bad. Just short-circuit instead. Change-Id: I84266d1c82de9833a6477e39ecee99df4439a491
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
|
||||
<groupId>gwtexpui</groupId>
|
||||
<artifactId>gwtexpui</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.3.4-SNAPSHOT</version>
|
||||
<version>1.3.4</version>
|
||||
<name>gwtexpui</name>
|
||||
<description>Extended UI tools for GWT</description>
|
||||
<url>https://gerrit.googlesource.com/gwtexpui</url>
|
||||
|
@@ -247,7 +247,7 @@ public abstract class SafeHtml {
|
||||
* @return a new string, after the replacements have been made.
|
||||
*/
|
||||
public <T> SafeHtml replaceAll(List<? extends FindReplace> findReplaceList) {
|
||||
if (findReplaceList == null) {
|
||||
if (findReplaceList == null || findReplaceList.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@@ -17,9 +17,16 @@ package com.google.gwtexpui.safehtml.client;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SafeHtml_ReplaceTest extends TestCase {
|
||||
public void testReplaceEmpty() {
|
||||
SafeHtml o = html("A\nissue42\nB");
|
||||
assertSame(o, o.replaceAll(null));
|
||||
assertSame(o, o.replaceAll(Collections.<FindReplace> emptyList()));
|
||||
}
|
||||
|
||||
public void testReplaceOneLink() {
|
||||
SafeHtml o = html("A\nissue 42\nB");
|
||||
SafeHtml n = o.replaceAll(repls(
|
||||
|
Reference in New Issue
Block a user