fix(libreoffice): fix CSV export crash and add LibreOffice Calc category#567
Open
gingeekrishna wants to merge 4 commits into
Open
fix(libreoffice): fix CSV export crash and add LibreOffice Calc category#567gingeekrishna wants to merge 4 commits into
gingeekrishna wants to merge 4 commits into
Conversation
…gory LibreOffice Writer has no CSV export filter. The shared filter map used Text for csv in both directions, which made any Writer-category conversion to csv fail with: no export filter for <file>.csv found, aborting. Root cause: getFilters() looked up the same filters map for the infilter and the outfilter. Text is a valid *input* filter for reading delimiter- separated files in Writer but is not accepted as an *output* filter for the .csv extension. Fix: - Split into separate inputFilters / outputFilters maps so csv can remain readable by the text (Writer) category without offering it as a write target there. - Remove csv from properties.to.text so the UI/router no longer exposes the unsupported Writer → CSV path. - Populate the previously-empty filters.calc with correct LibreOffice Calc filter names and add spreadsheet formats to properties.from.calc / properties.to.calc, enabling conversions such as xlsx → csv, csv → xlsx, ods → xlsx, etc. via the Calc module. Fixes C4illin#561 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes LibreOffice CSV conversion failures by separating input vs output filter selection (preventing Writer→CSV export attempts) and adds a new LibreOffice Calc category to enable spreadsheet conversions with correct filters.
Changes:
- Split the LibreOffice filter map into
inputFiltersandoutputFilters, and updatedgetFilters()to select appropriately. - Removed unsupported Writer-category CSV output (
csv) fromproperties.to.textso the UI/router no longer advertises invalid conversions. - Added Calc format lists + filter mappings and introduced new tests covering spreadsheet paths and the CSV regression.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/converters/libreoffice.ts |
Adds Calc format support; splits input/output filter maps; updates filter selection logic; updates supported format properties. |
tests/converters/libreoffice.test.ts |
Adds regression + Calc-path tests validating the generated soffice CLI arguments. |
Comments suppressed due to low confidence (1)
src/converters/libreoffice.ts:220
getFilters()uses theinoperator to test membership in plain objects. SincefileType/convertToultimately come from user-controlled file extensions and request params, values like__proto__will match via the prototype chain and can produce incorrect filter lookups (or[object Object]in CLI args). Use an own-property check instead ofin.
return [null, null];
};
export function convert(
filePath: string,
fileType: string,
convertTo: string,
targetPath: string,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The conventional file extension for SYLK spreadsheets is .slk, not .sylk. Using sylk meant uploaded .slk files would never match the properties entry and would not receive the SYLK infilter. Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
1 task
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Closes #561.
Converting any document to CSV via LibreOffice fails with:
followed by an
ENOENTbecause the output file was never written.Root cause
getFilters()used a single shared filter map for both the--infilter(input) and--convert-to <format>:<filter>(output) arguments. The map contained:"Text"is a valid input filter for reading delimiter-separated files inside LibreOffice Writer, but it is not accepted as an output filter for the.csvextension — Writer simply has no CSV export filter. LibreOffice therefore aborts with the "no export filter found" error every time a Writer-category document (pdf, docx, odt, etc.) is converted to CSV.Fix
1. Separate input and output filter maps
Replaced the single
filtersobject withinputFiltersandoutputFilters.csvappears ininputFilters.text(Writer can open CSVs as plain text) but is absent fromoutputFilters.text(Writer cannot export CSV).getFilters()now looks up the right map for each side.2. Remove
csvfromproperties.to.textThe UI/router no longer offers any Writer-category to CSV path, since it is unsupported.
3. Add LibreOffice Calc category
filters.calcwas present in the code but completely empty. This PR fills it with correct LibreOffice Calc filter names and addsfrom.calc/to.calcformat lists, enabling spreadsheet conversions that were previously impossible:Calc MS Excel 2007 XML→Text - txt - csv (StarCalc)Text - txt - csv (StarCalc)→Calc MS Excel 2007 XMLcalc8→Calc MS Excel 2007 XMLMS Excel 97→calc8All existing tests continue to pass. Four new tests cover the Calc path and the regression.
Summary by cubic
Fixes CSV export crashes by separating input/output filters and removing the unsupported Writer→CSV path. Adds a Calc category with correct filters for spreadsheet conversions (xlsx↔csv, ods↔xlsx, xls↔ods) and corrects the SYLK (.slk) extension mapping.
Bug Fixes
inputFiltersandoutputFilters;getFilters()picks the right one.csvfromproperties.to.textto stop offering Writer→CSV..slkso SLK files match and use the SYLK infilter.Refactors
Written for commit cd913ff. Summary will update on new commits.