Applying github pull request https://github.com/apache/commons-lang/pull/5, linked as LANG-928, fixing a bug in OctalEscaper trying to parse octal numbers longer than 3 digits
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1535911 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
38f8b88528
commit
6ea7f2f7af
|
@ -22,6 +22,7 @@
|
|||
<body>
|
||||
|
||||
<release version="3.2" date="TBA" description="Next release">
|
||||
<action issue="LANG-928" type="fix">OctalUnescaper has bugs when parsing octals starting with a zero</action>
|
||||
<action issue="LANG-905" type="fix">EqualsBuilder returns true when comparing arrays, even when the elements are different</action>
|
||||
<action issue="LANG-774" type="add" due-to="Erhan Bagdemir">Added isStarted, isSuspended and isStopped to StopWatch</action>
|
||||
<action issue="LANG-917" type="fix" due-to="Arne Burmeister">Fixed exception when combining custom and choice format in ExtendedMessageFormat</action>
|
||||
|
|
|
@ -50,6 +50,10 @@ public class OctalUnescaper extends CharSequenceTranslator {
|
|||
end--; // rollback
|
||||
break;
|
||||
}
|
||||
// only 3 characters applicable for Octal
|
||||
if (end - start >= 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out.write( Integer.parseInt(input.subSequence(start, end).toString(), 8) );
|
||||
|
|
|
@ -44,15 +44,44 @@ public class OctalUnescaperTest {
|
|||
|
||||
input = "\\378 and";
|
||||
result = oue.translate(input);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\378 and", result);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\37" + "8 and", result);
|
||||
|
||||
input = "\\378";
|
||||
result = oue.translate(input);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\378", result);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\37" + "8", result);
|
||||
|
||||
input = "\\1";
|
||||
result = oue.translate(input);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\1", result);
|
||||
|
||||
input = "\\036";
|
||||
result = oue.translate(input);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\036", result);
|
||||
|
||||
input = "\\0365";
|
||||
result = oue.translate(input);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\036" + "5", result);
|
||||
|
||||
input = "\\003";
|
||||
result = oue.translate(input);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\003", result);
|
||||
|
||||
input = "\\0003";
|
||||
result = oue.translate(input);
|
||||
assertEquals("Failed to unescape octal characters via the between method", "\000" + "3", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutOfRange() {
|
||||
final OctalUnescaper oue = new OctalUnescaper();
|
||||
|
||||
String input = "\\999";
|
||||
try {
|
||||
String result = oue.translate(input);
|
||||
fail("NumberFormatException was expected for input: " + input);
|
||||
} catch(NumberFormatException nfe) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue