-
Notifications
You must be signed in to change notification settings - Fork 44
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
Escape formulas in XLSX #38
Conversation
My initial though was that I dont want to burden this library with every single option that axlsx has built in. I almost think you could just manually escape any user inputted string that you think may nefarious. All axlsx does is check if the cells value starts with an "=" to determine if its a formula. So all you would have to do to escape any user input text is add a single quote to the beginning of the text. Ex. That being said I am sure many apps simply dont use formulas at all in their spreadsheet so this would actually be a good feature. I have made a few comments and we can go from there. |
@westonganger could you approve the workflows/build to run in this PR? |
Yeah, I'd figure that creating spreadsheets where some of the fields contain direct user input (names and addresses and such) are a big majority compared to use cases that involve formulas, so it would make all the more sense to provide security by default. |
@@ -104,7 +104,7 @@ def to_axlsx_package(opts={}, package=nil) | |||
end | |||
end | |||
|
|||
sheet.add_row row_data, style: styles, types: types | |||
sheet.add_row row_data, style: styles, types: types, escape_formulas: options[:escape_formulas] |
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.
Can we make the headers rows use escape_formulas: options[:escape_formulas]
just the same as the data rows
This adds an
escape_formulas
option to the XLSX generating methods in order to avoid formula injection when generating XLSX. The header row is additionally always escaped.Usage: