本文整理了Java中org.apache.poi.openxml4j.util.ZipSecureFile.getMaxTextSize()
方法的一些代码示例,展示了ZipSecureFile.getMaxTextSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipSecureFile.getMaxTextSize()
方法的具体详情如下:
包路径:org.apache.poi.openxml4j.util.ZipSecureFile
类名称:ZipSecureFile
方法名:getMaxTextSize
[英]Returns the current maximum allowed text size. See setMaxTextSize() for details.
[中]返回当前允许的最大文本大小。有关详细信息,请参阅setMaxTextSize()。
代码示例来源:origin: org.apache.poi/poi-ooxml
protected void checkMaxTextSize(CharSequence text, String string) {
if(string == null) {
return;
}
int size = text.length() + string.length();
if(size > ZipSecureFile.getMaxTextSize()) {
throw new IllegalStateException("The text would exceed the max allowed overall size of extracted text. "
+ "By default this is prevented as some documents may exhaust available memory and it may indicate that the file is used to inflate memory usage and thus could pose a security risk. "
+ "You can adjust this limit via ZipSecureFile.setMaxTextSize() if you need to work with files which have a lot of text. "
+ "Size: " + size + ", limit: MAX_TEXT_SIZE: " + ZipSecureFile.getMaxTextSize());
}
}
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testZipBombConfiguration() throws Exception {
Long maxEntrySizeVal = 3L * 1024 * 1024 * 1024;
Long maxTextSizeVal = 2L * 1024 * 1024 * 1024;
Double minInflateRatioVal = 0.123d;
// First set the property values
System.setProperty( Const.KETTLE_ZIP_MAX_ENTRY_SIZE, maxEntrySizeVal.toString() );
System.setProperty( Const.KETTLE_ZIP_MAX_TEXT_SIZE, maxTextSizeVal.toString() );
System.setProperty( Const.KETTLE_ZIP_MIN_INFLATE_RATIO, minInflateRatioVal.toString() );
//ExcelInput excelInput = new ExcelInput( null, null, 0, null, null );
// Initializing the ExcelInput step should make the new values to be set
meta.setSpreadSheetType( SpreadSheetType.SAX_POI );
init( "Balance_Type_Codes.xlsx" );
// Verify that the setted values were used
assertEquals( maxEntrySizeVal, (Long) ZipSecureFile.getMaxEntrySize() );
assertEquals( maxTextSizeVal, (Long) ZipSecureFile.getMaxTextSize() );
assertEquals( minInflateRatioVal, (Double) ZipSecureFile.getMinInflateRatio() );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testZipBombConfiguration_Default() throws Exception {
// First set some random values
Long bogusMaxEntrySize = 1000L;
ZipSecureFile.setMaxEntrySize( bogusMaxEntrySize );
Long bogusMaxTextSize = 1000L;
ZipSecureFile.setMaxTextSize( bogusMaxTextSize );
Double bogusMinInflateRatio = 0.5d;
ZipSecureFile.setMinInflateRatio( bogusMinInflateRatio );
// Verify that the bogus values were set
assertEquals( bogusMaxEntrySize, (Long) ZipSecureFile.getMaxEntrySize() );
assertEquals( bogusMaxTextSize, (Long) ZipSecureFile.getMaxTextSize() );
assertEquals( bogusMinInflateRatio, (Double) ZipSecureFile.getMinInflateRatio() );
// Initializing the ExcelInput step should make the new values to be set
meta.setSpreadSheetType( SpreadSheetType.SAX_POI );
init( "Balance_Type_Codes.xlsx" );
// Verify that the default values were used
assertEquals( Const.KETTLE_ZIP_MAX_ENTRY_SIZE_DEFAULT, (Long) ZipSecureFile.getMaxEntrySize() );
assertEquals( Const.KETTLE_ZIP_MAX_TEXT_SIZE_DEFAULT, (Long) ZipSecureFile.getMaxTextSize() );
assertEquals( Const.KETTLE_ZIP_MIN_INFLATE_RATIO_DEFAULT, (Double) ZipSecureFile.getMinInflateRatio() );
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
protected void checkMaxTextSize(CharSequence text, String string) {
if(string == null) {
return;
}
int size = text.length() + string.length();
if(size > ZipSecureFile.getMaxTextSize()) {
throw new IllegalStateException("The text would exceed the max allowed overall size of extracted text. "
+ "By default this is prevented as some documents may exhaust available memory and it may indicate that the file is used to inflate memory usage and thus could pose a security risk. "
+ "You can adjust this limit via ZipSecureFile.setMaxTextSize() if you need to work with files which have a lot of text. "
+ "Size: " + size + ", limit: MAX_TEXT_SIZE: " + ZipSecureFile.getMaxTextSize());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!