Optional domain whitelist to be used when loading HTML files.
public string DomainWhitelist { get; set; }
Public Property DomainWhitelist() As String
Get
Set
public:
property String^ DomainWhitelist
{
String^ get()
void set(String^ value)
}
Optional domain whitelist to be used when loading HTML files. The default value is null.
DomainWhitelist can be used to allow loading resources from only certain domains when loading HTML files. The engine will loop through each resource in the input HTML and clears it if it does not belong to the specified domains.
By default, the value of DomainWhitelist is null and all domains are allowed. To allow domains only from certain domains, add them to this property as a string separated by the pipe (|
) character.
The engine will remove the domains of the following HTML elements: <image>
or <a>
elements by selecting and clearing the src
or href
attributes. Therefore, domains not in the whitelist are not reached.
For instance, assume the following HTML file:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p>Image1</p>
<div class="tutorial-image"><img src="https://www.domain1.com/images/image1.jpg" title="DomainWhitelist Property"/></div>
<p>Image2</p>
<div class="tutorial-image"><img src="https://www.domain2.com/images/image2.jpg" title="DomainWhitelist Property"/></div>
<p>Image3</p>
<div class="tutorial-image"><img src="https://www.domain3.com/images/image3.jpg" title="DomainWhitelist Property"/></div>
</body>
</html>
When loading this file as raster or SVG image, the HTML engine will downloads all images and renders them into the output.
To enable resources only from domain1, set the value of DomainWhitelist as follows:
rasterCodecsInstance.Options.Html.Load.DomainWhitelist = "domain1.com";
Re-load the file and notice how only image1 is loaded and rendered.
To enable resources only from domain1 and domain2, set the value of DomainWhitelist as follows:
rasterCodecsInstance.Options.Html.Load.DomainWhitelist = "domain1.com|domain2.com";
Re-load the file and notice how image1 and image 2 are loaded and rendered.
To disable all resources from external domains, set DomainWhitelist to a value that will always fail the test, for example:
rasterCodecsInstance.Options.Html.Load.DomainWhitelist = "does-not-exist-domain";
For an example, refer to CodecsHtmlOptions.
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document