Repository navigation
Untrusted Text
English | Русский
The viewer is often given text that nobody in your application wrote: a chat message, the answer of a language model, a file from the internet. Such text cannot run code in the viewer, but its images can send requests in its name.
The standard loader loads an image by its address as soon as the image is shown:
-
A leak of the Windows password hash.
or a UNC path makes Windows connect to that server and offer it the NTLM hash of the account. Such paths are blocked by default. -
Data leaving with the address. A model told by an injected instruction to show
with your data in the address sends that data just by being shown. - Tracking. The server of an image learns who opened the message and when.
ImagePolicy decides which images reach the loader; an image that does not pass shows its alt text.
The property is inherited: set it on a window or a list of messages.
| Policy | Loads |
|---|---|
MdImagePolicy.Default |
everything the loader can, except files on other computers |
MdImagePolicy.Offline |
own files, application resources and images inside the document — no network |
MdImagePolicy.Untrusted |
only application resources and images inside the document (data:) |
ChatView.xaml, a list of messages:
<ListBox ItemsSource="{Binding Messages}"
md:MarkdownViewer.ImagePolicy="{x:Static md:MdImagePolicy.Untrusted}" />A policy of your own lists the schemes and the hosts of the web it lets through.
MainWindow.xaml.cs, in the constructor after InitializeComponent() (using Beresta.Markdown.Wpf;):
Viewer.ImagePolicy = new MdImagePolicy
{
Schemes = ["https", "data"],
Hosts = ["cdn.example.com"]
};AllowNetworkFiles = true lets files on other computers through — for documents that really live on a
network share.
- Links do not open by themselves: only on a click, and the standard opener opens only addresses of the web and mail — see Application Links.
- Copying puts on the clipboard the HTML of what is on the screen: an image the policy did not let through goes as its alt text — see Copying.
-
HTML does not run: known tags only format the text, the rest is shown as text — see
How It Renders. An
<img>is an image like any other and obeysImagePolicy. To show every tag as text, turn HTML off withDisableHtml()inPipelineSetup— see Supported Markdown. - Deep nesting does not overflow the stack: quotes, lists and emphasis nested deeper than the limit are shown as their source text — see How It Renders.
Beresta.Markdown.Wpf · Issues · MIT License
Basics
- Getting Started
- How It Renders
- Supported Markdown
- Settings and Hooks
- Scrolling and Virtualization
- Comparison
Working with Text
Appearance
Integration
- Application Links
- Images
- Untrusted Text
- Task Lists
- Source Lines and Two Panes
- Coordinates
- Live Preview
Editing
Your Own Syntax
Ready-made Extensions
Основы
- Начало работы
- Как рисует вьюер
- Что поддерживается
- Настройки и перехват
- Прокрутка и виртуализация
- Сравнение
Работа с текстом
Оформление
Встраивание в приложение
- Ссылки приложения
- Картинки
- Чужой текст
- Списки задач
- Строки исходника и две панели
- Координаты
- Живой предпросмотр
Правка
Свой синтаксис
Готовые расширения