SvgImageLimits Class
Contains limits that help protect the application from SVG images that require excessive resources to load or render.
Namespace: DevExpress.Utils.Svg
Assembly: DevExpress.Data.v26.1.dll
NuGet Package: DevExpress.Data
Declaration
Remarks
Use the SvgImageLimits class to change limits on the size of SVG images and on references between SVG elements (<use> elements, fill/stroke="url(#id)", and clip-path="url(#id)"):
| Property | Default Value | Description |
|---|---|---|
| MaxElementDepth | 64 | The maximum nesting depth of elements in an SVG image. If an image exceeds this limit, the application does not load the image and throws an SvgImageLimitsExceededException. |
| MaxElementCount | 65,536 | The maximum number of elements in an SVG image. The limit counts an element (together with its child elements) again each time a <use> element, clip path, pattern fill, or pattern stroke refers to this element. If an image exceeds this limit, the application does not load the image and throws an SvgImageLimitsExceededException. |
| MaxReferenceDepth | 16 | The maximum depth of nested references that the renderer follows. The renderer does not follow deeper references and renders the image partially. |
| MaxReferencedElementCount | 16,384 | The maximum number of referenced elements that the renderer draws in one image. The renderer skips elements over the limit. |
| MaxReferencedPointCount | 131,072 | The maximum number of points in referenced paths that the renderer draws in one image. The renderer skips paths over the limit. |
| MaxClipPathReferencedPointCount | 8,192 | The maximum number of points in referenced shapes that the renderer adds to a clip path. The renderer does not add shapes over the limit to the clip path. |
Limits apply to the entire process. Set limits once at application startup, before the application loads SVG images. Set a property to 0 to disable the corresponding limit.
Warning
Raise or disable SVG image limits only if all SVG images in your application come from trusted sources. An SVG image from an untrusted source can cause a denial of service.
The following example changes SVG image limits:
using DevExpress.Utils.Svg;
// Call at application startup.
SvgImageLimits.MaxElementCount = 256 * 1024;
SvgImageLimits.MaxReferencedElementCount = 64 * 1024;
SvgImageLimits.MaxReferencedPointCount = 0; // Disables the limit.
For additional information, refer to the following help topic: SVG Image Limits.