mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
add extra max size config
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898233 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4496e7761f
commit
189552425d
@ -81,6 +81,19 @@ public class TSPTimeStampService implements TimeStampService {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(TSPTimeStampService.class);
|
||||
|
||||
// how large a timestamp response is expected to be
|
||||
// can be overwritten via IOUtils.setByteArrayMaxOverride()
|
||||
private static final int DEFAULT_TIMESTAMP_RESPONSE_SIZE = 10_000_000;
|
||||
private static int MAX_TIMESTAMP_RESPONSE_SIZE = DEFAULT_TIMESTAMP_RESPONSE_SIZE;
|
||||
|
||||
public static void setMaxTimestampResponseSize(int maxTimestampResponseSize) {
|
||||
MAX_TIMESTAMP_RESPONSE_SIZE = maxTimestampResponseSize;
|
||||
}
|
||||
|
||||
public static int getMaxTimestampResponseSize() {
|
||||
return MAX_TIMESTAMP_RESPONSE_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the digest algorithm to corresponding OID value.
|
||||
*/
|
||||
@ -165,7 +178,7 @@ public class TSPTimeStampService implements TimeStampService {
|
||||
}
|
||||
|
||||
try (InputStream stream = huc.getInputStream()) {
|
||||
responseBytes = IOUtils.toByteArray(stream);
|
||||
responseBytes = IOUtils.toByteArray(stream, MAX_TIMESTAMP_RESPONSE_SIZE);
|
||||
}
|
||||
LOG.atDebug().log(() -> new SimpleMessage("response content: " + HexDump.dump(responseBytes, 0, 0)));
|
||||
} finally {
|
||||
|
||||
@ -77,6 +77,8 @@ public class XMLSlideShow extends POIXMLDocument
|
||||
//arbitrarily selected; may need to increase
|
||||
private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
|
||||
private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
|
||||
private static final int DEFAULT_MAX_IMAGE_SIZE = 100_000_000;
|
||||
private static int MAX_IMAGE_SIZE = DEFAULT_MAX_IMAGE_SIZE;
|
||||
|
||||
private CTPresentation _presentation;
|
||||
private final List<XSLFSlide> _slides = new ArrayList<>();
|
||||
@ -101,6 +103,20 @@ public class XMLSlideShow extends POIXMLDocument
|
||||
return MAX_RECORD_LENGTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param length the max image size allowed for XMLSlideShow
|
||||
*/
|
||||
public static void setMaxImageSize(int length) {
|
||||
MAX_IMAGE_SIZE = length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the max image size allowed for XMLSlideShow
|
||||
*/
|
||||
public static int getMaxImageSize() {
|
||||
return MAX_IMAGE_SIZE;
|
||||
}
|
||||
|
||||
public XMLSlideShow() {
|
||||
this(empty());
|
||||
}
|
||||
@ -556,7 +572,7 @@ public class XMLSlideShow extends POIXMLDocument
|
||||
*/
|
||||
@Override
|
||||
public XSLFPictureData addPicture(InputStream is, PictureType format) throws IOException {
|
||||
return addPicture(IOUtils.toByteArray(is), format);
|
||||
return addPicture(IOUtils.toByteArray(is, MAX_IMAGE_SIZE), format);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -50,14 +50,12 @@ import org.apache.poi.sl.usermodel.SlideShow;
|
||||
import org.apache.poi.sl.usermodel.SlideShowFactory;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LocaleUtil;
|
||||
|
||||
/** Handler for ppt and pptx files */
|
||||
@Internal
|
||||
class PPTHandler extends MFProxy {
|
||||
private SlideShow<?,?> ppt;
|
||||
private Slide<?,?> slide;
|
||||
private Charset defaultCharset = LocaleUtil.CHARSET_1252;
|
||||
|
||||
@Override
|
||||
public void parse(File file) throws IOException {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user