Skip to content

Commit

Permalink
docs(html): template languages
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Jan 5, 2025
1 parent 215fece commit 3299895
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/coding/html.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,24 @@ Level: **Mandatory**
{{ username }} {{ tags | join(',') }}
```

### Unfiltered user input MUST be HTML escaped

Level: **Mandatory**

```jinja
{# ❌ bad #}
<p>{{ description }}</p>
<script>
window.user = {{ user | dump }}
</script>
{# ✅ good #}
{{ description | escaped }}
<script>
window.user = {{ user | dump | escaped }}
</script>
```

## Credits

- [Guo Yunhe](https://github.com/guoyunhe)
Expand Down
18 changes: 18 additions & 0 deletions docs/coding/html.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,24 @@ order: 1
{{ username }} {{ tags | join(',') }}
```

### 未过滤的用户输入必须 HTML 转义

等级: **强制**

```jinja
{# ❌ 错误 #}
<p>{{ description }}</p>
<script>
window.user = {{ user | dump }}
</script>
{# ✅ 正确 #}
{{ description | escaped }}
<script>
window.user = {{ user | dump | escaped }}
</script>
```

## 作者署名

- [郭云鹤(鹤仙)](https://github.com/guoyunhe)
Expand Down

0 comments on commit 3299895

Please # to comment.