Fix for LANG-477 OutOfMemory with custom format registry and a pattern containing single quotes - thanks to Duncan Eley
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@733169 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb8b39b145
commit
a38e2e942d
|
@ -419,6 +419,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
|||
int start = pos.getIndex();
|
||||
char[] c = pattern.toCharArray();
|
||||
if (escapingOn && c[start] == QUOTE) {
|
||||
next(pos);
|
||||
return appendTo == null ? null : appendTo.append(QUOTE);
|
||||
}
|
||||
int lastHold = start;
|
||||
|
|
|
@ -92,6 +92,15 @@ public class ExtendedMessageFormatTest extends TestCase {
|
|||
assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"foo", "BAR"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Bug LANG-477 - out of memory error with escaped quote
|
||||
*/
|
||||
public void testEscapedQuote_LANG_477() {
|
||||
String pattern = "it''s a {0,lower} 'test'!";
|
||||
ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry);
|
||||
assertEquals("it's a dummy test!", emf.format(new Object[] {"DUMMY"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test extended and built in formats.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue