FastComments.com


Здесь мы рассмотрим формат комментариев FastComments, функции, поддерживаемые при написании комментариев, как форматировать текст и различные фильтры и меры безопасности, встроенные в систему.


Базовое форматирование Internal Link

FastComments использует комбинацию Markdown и простого подмножества HTML для написания комментариев.

Хороший ресурс по синтаксису Markdown здесь.

Для наиболее распространённого форматирования вы можете использовать панель инструментов форматирования, чтобы делать такие вещи, как выделение текста жирным или курсивом.

Некоторые примеры синтаксиса:

  • Жирный:
    • **жирный**
    • <b>жирный текст</b>
  • Курсив:
    • *курсив*
    • <i>курсивный текст</i>
  • Зачёркнутый:
    • ~~зачёркнутый~~
    • <strike>зачёркнутый</strike>
  • Цитаты:
    • > цитата

Обратите внимание, что заголовки Markdown не поддерживаются.

Ссылки могут быть написаны как их сырой URL, без HTML или другого синтаксиса, и по умолчанию ссылка будет преобразована в кликабельную ссылку с target="nofollow noopener" для отпугивания спамеров. Некоторые сайты могут отключить автоматическое создание ссылок.

Нумерованные списки можно написать так:

1. Первый пункт.
2. Второй пункт.
3. Третий пункт.

То же самое для маркированных списков:

- Один пункт.
- Другой пункт.

Для сообществ, ориентированных на программирование, код можно поделиться, вставив его в область комментария, и язык будет автоматически определён и отформатирован. Код можно добавить в теги <code></code> или блоки кода Markdown с обратными кавычками.

Безопасность Internal Link

There are multiple aspects to security when letting people add content to a website and then rendering that content on many different types of devices.

Preventing Formatting Abuse

People can write content that is intentionally visually distracting and detracts value from discussions by abusing text formatting.

FastComments does a number of things to prevent abuse in regard to formatting:

  • Large repeated consecutive newlines are collapsed.
  • We don't render headings (they become normal text).
  • We don't allow CSS or custom colors.

Preventing Exploits

Exploits can be created in systems that render HTML. FastComments does several things to prevent this:

  • We only allow an explicitly defined set of HTML tags.
  • We only allow an explicitly defined set of HTML tag attributes.
  • We purify and sanitize all inputs.
    • This is done via the DOMPurify and sanitizeHtml libraries.
    • We chose these libraries as being well tested (having over 4 and 1 million downloads per week, respectively).

This means that users can't do things like write <script> or <style> tags, or try to add onload=alert() type scripts to images or other content.

The HTML tags we allow are as follows:

  • <b>
  • <em>
  • <u>
  • <i>
  • <strike>
  • <pre>
  • <span>
  • <code>
  • <img>
  • <a>
  • <strong>
  • <ul>
  • <ol>
  • <li>
  • <br>

The <iframe> tag is not allowed by default. If you turn on Allow Media Embeds, iframes are also permitted, but only when their source is one of a built-in list of trusted providers (such as YouTube, Vimeo, SoundCloud, and Spotify) or a hostname you have explicitly added. Iframes from any other source are removed.