Repository navigation
Description
Reproduced on: SolidCraft 0.40.0-rc.2, built from source at main 73e188d on Windows 11 x86_64, through solidcraft-cli run.
SolidCraft writes four kinds of CSV file: the bill of materials (assembly.bom), the parameters (parameters.export), the bend table (sheet.export_bend_table) and motion samples (motion.export). Their text fields come from the design: part numbers, descriptions, revisions, names, expressions and comments. A spreadsheet reads a field that starts with =, +, - or @ as a formula. So these files can open in a spreadsheet with values that aren't the design's: a part numbered =1+1 shows as 2. A design received from someone else can put a formula into the spreadsheet of whoever exports its BOM. This is a hardening change: the fix keeps such a field as text.
Steps
{"commands":[
{"command":"component.create","params":{"name":"Shim"}},
{"command":"solid.box","params":{"length":40,"width":20,"height":3}},
{"command":"component.activate","params":{"component":0}},
{"command":"component.metadata.set","params":{"component":"Shim","part_number":"=1+1","description":"-5 mm shim","revision":"@SUM(1,1)"}},
{"command":"assembly.bom","params":{"path":"bom.csv"}},
{"command":"parameters.add","params":{"name":"gap","expression":"=5","comment":"+2 for the fit"}},
{"command":"parameters.export","params":{"format":"csv","path":"params.csv"}}
]}Then open bom.csv and params.csv in a spreadsheet.
Expected
The spreadsheet shows each field as the design has it: =1+1, -5 mm shim, @SUM(1,1), =5, +2 for the fit.
Actual
Corrected 7 Nov: the first Actual came from a drawings build, not main. The files below are from main 73e188d (114 and 77 bytes). The quoting is the same; main's BOM file has 6 columns, not 8.
The files hold the fields as they are, with nothing to keep them text:
bom.csv:
"item","part_number","description","revision","count","definition"
"1","=1+1","-5 mm shim","@SUM(1,1)","1","Shim"
params.csv:
name,unit,expression,value,comment,favorite
gap,mm,=5,5,+2 for the fit,false
Quoting a field doesn't make it text: a spreadsheet takes the quotes off and then reads the field. What each program does with these fields:
- Excel reads
=,+,-and@at the start as a formula (+,-and@come from Lotus 1-2-3).=1+1shows2.-5 mm shimis read as the formula=-5 mm shim, which shows#NAME?. - LibreOffice Calc reads
=as a formula when its Text Import's "Evaluate formulas" is on. That option has been off by default since 2021 (tdf#114878). - OWASP's CSV Injection page lists the same triggers, plus tab, CR, LF and the full-width
= + - @. Its first mitigation is a'before such a field, inside quotes.
I have no spreadsheet program on this computer, so the effects above come from OWASP's page, LibreOffice's help and Excel's long-documented formula entry, not from a screenshot.
Where it happens
Four writers, each with its own quoting, and none of them guards a formula:
crates/doc/src/params.rs:487params_csv: quotes a field only when it holds,,"or a line break.crates/engine/src/cmd/bom.rs:402quote: always quotes.crates/engine/src/cmd/sheet.rs:1153: its ownquote, always quotes.crates/engine/src/cmd/motion.rs:854: doesn't quote. A,in an occurrence name becomes a space, and a"or a line break breaks the row.
A ; inside an unquoted parameter field also matters. Where a spreadsheet's separator is ; (much of Europe), the field splits into a new cell, and that cell can start with =.
Suggestion
One shared CSV field writer that all four use:
- A text field that starts with a trigger gets a
'in front, as OWASP says. - A field that is a whole plain number (
-5,+5,1e-9) stays as it is. A spreadsheet reads it as that number, and a negative coordinate stays a number. parameters.importtakes the'off again, so an exported=5expression imports back as=5(Accept a leading = in expressions, so a fillet radius can be =d3 (#4681) #4686).;and tab join the characters that make a field quoted.
Activity
github-actions commentedon Nov 6, 2026
Claimed by @CamWight through #12729. The claim lapses after 14 days without pushes.
CamWight commentedon Nov 7, 2026
I've corrected the Actual section above. The first version showed the files from a
drawingsbuild, which writes 8 columns in the BOM file. The files there now come frommain73e188d, where the BOM file has 6 columns. The problem is the same in both builds: the fields that start with=,-or@are written as they are. I also fixed one line number:bom.rs:402, not 401.CSV exports: a field that starts with =, +, - or @ stays text in a sp…