Skip to content

Honor ResolveExternalImages for image loading#501

Merged
wieslawsoltes merged 3 commits into
masterfrom
fix/resolve-external-images-policy
May 11, 2026
Merged

Honor ResolveExternalImages for image loading#501
wieslawsoltes merged 3 commits into
masterfrom
fix/resolve-external-images-policy

Conversation

@wieslawsoltes
Copy link
Copy Markdown
Owner

PR Summary: Honor External Image Resolution Policy

Issue

Fixes #448.

SvgDocument.ResolveExternalImages = ExternalType.None was not honored by the Svg.Skia image-loading path. The upstream SVG model guards external image resolution before opening local or remote resources, but the Svg.Skia SvgService.GetImage path used by retained rendering and filter image rendering loaded the resolved URI directly.

Changes

  • Added an external image policy check in SvgService.GetImage before loading non-data image URIs.
  • Kept data URI handling unchanged so embedded image data continues to render without being treated as an external local or remote resource.
  • Added regression tests for the shared image-loading service:
    • ExternalType.None returns null and does not invoke the asset loader for a local file URI.
    • ExternalType.Local still permits loading a local file URI and invokes the asset loader once.

Commit Breakdown

  1. Honor external image resolution policy

    • Production change in src/Svg.Model/Services/SvgService.cs.
    • Applies SvgDocument.ResolveExternalImages.AllowsResolving(uri) before calling GetImageFromWeb.
  2. Add external image policy tests

    • Adds tests/Svg.Model.UnitTests/SvgServiceExternalImageTests.cs.
    • Covers disabled and allowed local-image resolution behavior.

Validation

Completed locally:

  • dotnet format Svg.Skia.slnx --no-restore
  • dotnet build Svg.Skia.slnx -c Release
  • dotnet test Svg.Skia.slnx -c Release --no-restore
  • dotnet test tests/Svg.Model.UnitTests/Svg.Model.UnitTests.csproj -c Release --no-restore --filter "FullyQualifiedName~SvgServiceExternalImageTests"
  • git diff --check

The full Release build completed with existing warnings in unrelated projects, including package vulnerability advisories, obsolete generated Skia API usage, and nullable warnings. The full Release test run completed successfully.

Notes

The change intentionally centralizes the policy check in SvgService.GetImage, so direct <image> rendering and feImage filter paths receive the same external-resource behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SvgImage loads external images even if SvgDocument.ResolveExternalImages is set to None

1 participant