Repository navigation
feat(browser): accept standalone SVG text through Ctrl-drag - #813
Conversation
|
Thanks, @1644ye! Before reviewing the code, a question about scope. Converting SVG markup selected as text (from a page or an editor) is a fairly niche case, and the PR adds a new setting for it (on by default) plus a parser for mixed and escaped fragments. Please open an issue describing:
Then we can agree on whether it belongs in Filee and how before you spend more time here. New features start with an issue so the design is settled first. I'll keep this draft open in the meantime. |
|
Thanks for the scope feedback. I opened #820 with the concrete workflow, existing behavior, and the smaller integration options for discussion. This PR will remain draft while we agree on the requirement and scope. |
|
Reworked to the agreed scope in Only a single, well-formed standalone SVG text selection is added to Ctrl-drag. The setting, HTML extraction, escaped-markup handling and broad renderer changes are removed. Unresolved external resources become an actionable failed result. Parser tests and real drag-enter/drop tests through PNG/PDF are included.
Marking ready for your CI approval. This PR contains no extension changes. |
KnifeLemon
left a comment
There was a problem hiding this comment.
Thanks @1644ye, this matches the scope we agreed in #820:
- Only a single, well-formed
<svg>selection is accepted.InlineSvg.Readchecks the prefix first, parses with DTDs prohibited and no resolver, caps the size, and rejects anything else in the document. Ordinary text still doesn't wake the donut (MayOffer). - A missing
xmlns(common in HTML selections) gets the SVG namespace, so converters read it. - Unresolved
href, CSSurl()and@importbecome a failed result with an explanation instead of a blank picture, anddata:and#fragmentreferences pass. - The tests cover accepted, rejected and almost-well-formed SVG, and drops through to PNG and PDF.
One thing to keep in mind, not blocking: MayOffer runs on every drag-over, and for an SVG selection it parses the whole text each time. That's fine at today's 4 MB cap; if it ever shows up in profiles, caching the last text and result would remove it.
The Windows ARM64 job was cancelled (not a test failure), so I've rerun it. I'll merge once it's green.
Accept a selected, standalone, well-formed
<svg …>…</svg>through the existing Ctrl-drag path. Surrounding whitespace is allowed. Ordinary text, text links, mixed HTML, sibling SVG roots, escaped markup and malformed XML retain their existing behavior. There is no new setting or browser extension in this PR.Selections are normalized to an SVG namespace when necessary. External image/font/stylesheet references are reported as a failed result with an actionable message; they are not silently rendered as a blank image. Embedded data resources and local fragment references remain supported.
Tests cover accepted/rejected/almost-well-formed XML, external dependencies, and Avalonia drag-enter/drop events through both PNG (pixel assertion) and PDF (drawn-path assertion). The missing-resource cases also exercise both targets and check that no output file remains.
Closes #820.
Validation on Windows / .NET 10, based on upstream
7fc129f:dotnet format Filee.slnx --no-restore --verify-no-changes: passed.dotnet testprojects passed: App 1,638; CLI 55; Core 773; Engines 1,942; Platform 94; Setup 206 (4,708 passed, zero failures in the final project runs).Test environment notes: App/engine tests used an isolated
FILEE_DATA_DIRso installed optional engines did not invalidate the upstream engine-install tests. Setup tests require the real default paths and were rerun without that override (206/206). One existing StallWatch timing assertion failed during the initial parallel workload; a complete Engines rerun passed (1,942 passed, 210 skipped). No engine, installer or timeout-test code was changed for these environment issues.