Fix "array index out of bounds" problem reported by LGTM.com
This commit is contained in:
committed by
Rossen Stoyanchev
parent
670cbb9aed
commit
f084b63286
@@ -28,6 +28,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ContentDisposition}
|
||||
@@ -36,7 +37,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*/
|
||||
public class ContentDispositionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void parseTest() {
|
||||
ContentDisposition disposition = ContentDisposition
|
||||
@@ -198,4 +198,22 @@ public class ContentDispositionTests {
|
||||
ReflectionUtils.invokeMethod(decode, null, "UTF-16''test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeHeaderFieldParamShortInvalidEncodedFilename() {
|
||||
Method decode = ReflectionUtils.findMethod(ContentDisposition.class,
|
||||
"decodeHeaderFieldParam", String.class);
|
||||
ReflectionUtils.makeAccessible(decode);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ReflectionUtils.invokeMethod(decode, null, "UTF-8''%A"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeHeaderFieldParamLongerInvalidEncodedFilename() {
|
||||
Method decode = ReflectionUtils.findMethod(ContentDisposition.class,
|
||||
"decodeHeaderFieldParam", String.class);
|
||||
ReflectionUtils.makeAccessible(decode);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ReflectionUtils.invokeMethod(decode, null, "UTF-8''%A.txt"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user