# safe-markdown

Source: https://apigenie.pl/docs/linter/openapi/rules/safe-markdown

A rule of the OpenAPI linter, which reads OpenAPI 3.0, 3.1 and 3.2 documents. Since 0.0.1. Fixed by `--fix`. In the rulesets: Recommended at warning, Strict at error, All at error.

This rule checks that no description contains a `<script>` tag or an `eval()` call.

## Rule details

Descriptions are CommonMark, and CommonMark allows raw HTML, so a description is rendered as-is
by every documentation page built from the document. A script in it runs in the browser of every
reader of that page, with the page's cookies and origin.

The rule reports `Markdown contains <script> tag` and `Markdown contains eval() function` on the
object whose description has them.

## Examples

**Good**. Prose.

```yaml
components:
  schemas:
    User:
      type: object
      description: A user of the system.
```

**Bad**. A script in the description.

```yaml
components:
  schemas:
    User:
      type: object
      description: "A user of the system. <script>alert('Unsafe')</script>"
```

## Automatic fixes

`--fix` escapes the delimiters of the script elements and `eval()` calls it finds, so they render
as text. Code spans and fenced code blocks are left as they are, and so is the rest of the
Markdown.
