Skip to content

Fix BOM export losing link text and mangling numeric-looking values - #580

Merged
qu1ck merged 1 commit into
openscopeproject:masterfrom
DominikPalo:fix-bom-export-values
Oct 6, 2026
Merged

qu1ck merged 1 commit into
openscopeproject:masterfrom
DominikPalo:fix-bom-export-values

Conversation

@DominikPalo

Copy link
Copy Markdown
Contributor

Fixes three problems in saveBomTable (web/util.js), used by the CSV, TXT (TSV) and copy-to-clipboard exports.

Link/highlight text lost

For <mark> and <a> nodes the export read only node.firstChild.nodeValue. A link whose text starts with a filter highlight is <a><mark>https</mark>://…</a>, so its first child is an element and the cell exported as null. If the highlight was elsewhere in the link, only the text before it was exported. Cells now use node.textContent, which also covers marks nested inside links. Checkbox inputs are handled as before.

Numeric-looking values converted in CSV

Any value passing isNumeric was written as a bare number, so part codes such as 0805, 0x10 and 1e3 became 805, 16 and 1000 in the file. A value is now written unquoted only if String(+val) === val, i.e. converting it is lossless. Plain numbers like 10, 4.7 and -3 (and the row index/quantity columns) stay bare numbers.

Unescaped quotes in CSV header

Header names were wrapped in quotes without escaping embedded ", so a checkbox or field name containing a quote produced a malformed header row. They are now escaped the same way as cell values.

Testing

Generated a BOM from the KiCad Arduino_Uno template with Datasheet shown, injected test values into pcbdata, and captured the blobs passed to saveFile:

Case master this PR
Datasheet link, filter https (CSV and TSV) "null" / null "https://example.com/ds0.pdf"
Value 0805 (CSV) 805 "0805"
Values 0x10 / 1e3 (CSV) 16 / 1000 "0x10" / "1e3"
Highlight in the middle of a link truncated full URL
Value say "hi", checkbox name Pl"aced header row broken "say ""hi""", "Pl""aced"
4.7, -3, 10, ticked checkbox bare numbers, "✓"

No console errors.

Note that spreadsheet applications may still auto-convert a quoted "0805" on import; that is outside what the CSV can control, but the file itself now preserves the exact value.

🤖 Generated with Claude Code

saveBomTable read only the first child node of marks and links, so a
link whose text starts with a filter highlight exported as "null" and
other highlighted links were truncated. Use textContent instead.

CSV export also emitted any numeric-looking value as a bare number,
turning part codes like 0805, 0x10 or 1e3 into 805, 16 and 1000. Only
emit a bare number when that is lossless, and escape double quotes in
header names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qu1ck
qu1ck merged commit 8a8de31 into openscopeproject:master Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants