-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility to configure Apache POI #232
Open
martinstuder
wants to merge
2
commits into
master
Choose a base branch
from
feature/configure_poi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ export( | |
aref, | ||
aref2idx, | ||
col2idx, | ||
configurePOI, | ||
cref2idx, | ||
extractSheetName, | ||
idx2aref, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
############################################################################# | ||
# | ||
# XLConnect | ||
# Copyright (C) 2010-2024 Mirai Solutions GmbH | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
############################################################################# | ||
|
||
############################################################################# | ||
# | ||
# Configures Apache POI and related components. | ||
# See https://poi.apache.org/components/configuration.html | ||
# | ||
# Author: Martin Studer, Mirai Solutions GmbH | ||
# | ||
############################################################################# | ||
|
||
configurePOI <- function( | ||
zip_max_files = 1000L, | ||
zip_min_inflate_ratio = 0.001, | ||
zip_max_entry_size = 0xFFFFFFFF, | ||
zip_max_text_size = 10*1024*1024, | ||
max_size_byte_array = -1L | ||
) { | ||
ioutils <- J("org.apache.poi.util.IOUtils") | ||
ioutils$setByteArrayMaxOverride(as.integer(max_size_byte_array)) | ||
|
||
zip <- J("org.apache.poi.openxml4j.util.ZipSecureFile") | ||
zip$setMaxFileCount(rJava::.jlong(zip_max_files)) | ||
zip$setMinInflateRatio(zip_min_inflate_ratio) | ||
zip$setMaxEntrySize(rJava::.jlong(zip_max_entry_size)) | ||
zip$setMaxTextSize(rJava::.jlong(zip_max_text_size)) | ||
|
||
invisible() | ||
} |
Binary file renamed
BIN
+83.8 KB
inst/java/XLConnect-3.1.0.jar → inst/java/XLConnect-3.1.1-SNAPSHOT.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
\name{configurePOI} | ||
\alias{configurePOI} | ||
\title{ | ||
Configuring Apache POI | ||
} | ||
\description{ | ||
Configures Apache POI and related components. | ||
} | ||
\usage{ | ||
configurePOI(zip_max_files = 1000L, zip_min_inflate_ratio = 0.001, | ||
zip_max_entry_size = 0xFFFFFFFF, zip_max_text_size = 10*1024*1024, | ||
max_size_byte_array = -1L) | ||
} | ||
\arguments{ | ||
\item{zip_max_files}{Integer scalar specifying the maximum number of files | ||
allowed inside an *.xlsx file. Defaults to \code{1000}.} | ||
\item{zip_min_inflate_ratio}{Numeric scalar specifying the ratio between | ||
de- and inflated bytes to detect zip-bombs. If the compression ratio is | ||
better than the specified number an error will be thrown. Defaults to | ||
\code{0.001}.} | ||
\item{zip_max_entry_size}{Integer scalar specifying the maximum file size | ||
of a single zip entry in an *.xlsx file. Defaults to 4'294'967'295 bytes, | ||
which is 4GB.} | ||
\item{zip_max_text_size}{Integer scalar specifying the maximum number of | ||
characters of text that are extracted before an error is thrown. Defaults | ||
to 10'485'760.} | ||
\item{max_size_byte_array}{Integer scalar specifying the maximum number of | ||
bytes that should be possible to be allocated in a single step. Increasing | ||
this limit can help if you are dealing with large Excel files, but note that | ||
this may demand a larger heap space (see option \code{java.parameters}; e.g. | ||
\code{options(java.parameters = "-Xmx8192m")}. Defaults to -1, which means | ||
that record-specific limits apply.)} | ||
} | ||
\details{ | ||
Many of the settings exposed here exist for security reasons to prevent excessive | ||
memory consumption and protect against security vulnerabilities when processing | ||
documents provided by untrusted sources. | ||
} | ||
\references{ | ||
Apache POI configuration: \url{https://poi.apache.org/components/configuration.html} | ||
} | ||
\author{ | ||
Martin Studer\cr | ||
Mirai Solutions GmbH \url{https://mirai-solutions.ch} | ||
} | ||
\examples{ | ||
\dontrun{ | ||
configurePOI(zip_max_files = 5000L, max_size_byte_array = 250000000L) | ||
} | ||
} | ||
\keyword{IO} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setThresholdBytesForTempFiles
? Even if we would leave the default of not using temp files (in case we run on a readonly system), it seems like this may sometimes be needed when using large files.