Skip to content

Commit f3728ff

Browse files
committed
[LANG-1783] WordUtils.containsAllWords​() may throw
PatternSyntaxException Port change from Commons Text
1 parent d45f23e commit f3728ff

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ The <action> type attribute can be add,update,fix,remove.
5151
<action type="fix" dev="ggregory" due-to="Gary Gregory">Reduce spurious failures in org.apache.commons.lang3.ArrayUtilsTest methods that test ArrayUtils.shuffle() methods.</action>
5252
<action type="fix" dev="ggregory" due-to="Gary Gregory">MethodUtils cannot find or invoke a public method on a public class implemented in its package-private superclass.</action>
5353
<action type="fix" dev="ggregory" due-to="Stanislav Fort, Gary Gregory">org.apache.commons.lang3.concurrent.AtomicSafeInitializer.get() can spin internally if the FailableSupplier given to org.apache.commons.lang3.concurrent.AbstractConcurrentInitializer.AbstractBuilder.setInitializer(FailableSupplier) throws a RuntimeException.</action>
54+
<action issue="LANG-1783" type="fix" dev="ggregory" due-to="Arnout Engelen, Stanislav Fort, Gary Gregory">WordUtils.containsAllWords​() may throw PatternSyntaxException.</action>
5455
<!-- FIX Javadoc -->
5556
<action type="fix" dev="ggregory" due-to="Gary Gregory">[javadoc] General improvements.</action>
5657
<action type="fix" dev="ggregory" due-to="Gary Gregory">[javadoc] Fix thrown exception documentation for org.apache.commons.lang3.reflect.MethodUtils.getMethodObject(Class&lt;?&gt;, String, Class&lt;?&gt;...).</action>

src/main/java/org/apache/commons/lang3/text/WordUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public static boolean containsAllWords(final CharSequence word, final CharSequen
198198
if (StringUtils.isBlank(w)) {
199199
return false;
200200
}
201-
final Pattern p = Pattern.compile(".*\\b" + w + "\\b.*");
201+
final Pattern p = Pattern.compile(".*\\b" + Pattern.quote(w.toString()) + "\\b.*");
202202
if (!p.matcher(word).matches()) {
203203
return false;
204204
}

0 commit comments

Comments
 (0)