|
1 | 1 | <template> |
2 | 2 | <div class="container"> |
3 | | - <img class="logo" src="../assets/logo.svg"> |
| 3 | + <img class="logo" src="../assets/logo.svg" height="150" width="150" alt=""> |
4 | 4 | <h1>v-sanitize</h1> |
5 | 5 |
|
6 | 6 | <p><a href="https://vuejs.org/" target="_blank">Vue</a>'s default <code>v-text</code> is HTML-insensitive, while <code>v-html</code> doesn't perform sanitization by default.</p> |
7 | | - <p><code>v-sanitize</code> is a Vue directive for HTML sanitization, powered by the flexible <a href="https://www.npmjs.com/package/sanitize-html" target="_blank">sanitize-html</a>. The directive can receive either a string, that will undergo a partial sanitization if no modifier is present, or an array of two elements, the first being a <code>sanitize-html</code> allowlist (<a href="https://github.com/punkave/sanitize-html" target="_blank">know more here</a>) and the second being the string to be sanitized.</p> |
| 7 | + <p><code>v-sanitize</code> is a Vue directive for HTML sanitization, powered by the flexible <a href="https://www.npmjs.com/package/sanitize-html" target="_blank">sanitize-html</a>. The directive can receive either a string, that will undergo a partial sanitization if no modifier is present, or an array of two elements, the first being a <code>sanitize-html</code> allowlist (<a href="https://github.com/apostrophecms/sanitize-html" target="_blank">know more here</a>) and the second being the string to be sanitized.</p> |
8 | 8 | <pre class="editor" v-pre> |
9 | 9 | <code><<span class="red">div</span> <span class="orange">v-sanitize</span>="<span class="green">unsafe_html</span>"></<span class="red">div</span>></code> |
10 | 10 | </pre> |
11 | 11 |
|
| 12 | + <div class="warning"> |
| 13 | + <h2>Warning</h2> |
| 14 | + <p>The validation and sanitization of user-provided input should be performed on the back-end, before storing it on the database. You should resort to client-side input sanitization only if you don't control the back-end, e.g., consuming content from an external API.</p> |
| 15 | + </div> |
| 16 | + |
12 | 17 | <h2>Setup</h2> |
13 | 18 | <p>Start getting it with NPM or Yarn (<a href="https://www.npmjs.com/package/vue-sanitize-directive" target="_blank">see package</a>).</p> |
14 | 19 | <pre class="editor"> |
|
50 | 55 | <div class="demo" v-sanitize.nothing="html"></div> |
51 | 56 |
|
52 | 57 | <h3>Custom allowlists</h3> |
53 | | - <p>Edit the box below, as JSON. Read <a href="https://github.com/punkave/sanitize-html" target="_blank">sanitize-html docs</a> for more details.</p> |
| 58 | + <p>Edit the box below, as JSON. Read <a href="https://github.com/apostrophecms/sanitize-html" target="_blank">sanitize-html docs</a> for more details.</p> |
54 | 59 | <div class="table"> |
55 | 60 | <div class="row"> |
56 | 61 | <div class="col"> |
57 | | - <textarea rows="5" v-model="editableFilter"></textarea> |
| 62 | + <textarea aria-label="Allowlist" rows="5" v-model="editableFilter"></textarea> |
58 | 63 | <button @click="updateFilter()">Update allowlist</button> |
59 | 64 | </div> |
60 | 65 | <div class="col"> |
61 | | - <textarea rows="5" v-model="editableHtml"></textarea> |
| 66 | + <textarea aria-label="HTML input" rows="5" v-model="editableHtml"></textarea> |
62 | 67 | <button @click="updateHtml()">Update HTML</button> |
63 | 68 | </div> |
64 | 69 | <div class="col"> |
|
77 | 82 | import { FILTER_BASIC, FILTER_INLINE, FILTER_NOTHING, FILTER_STRIP } from 'vue-sanitize-directive' |
78 | 83 |
|
79 | 84 | const html = ` |
80 | | - <iframe src="https://www.example.org"></iframe> |
| 85 | + <iframe src="https://www.openstreetmap.org/export/embed.html" title="Example page"></iframe> |
81 | 86 | <p>This is a <strong>test</strong>.</p> |
82 | 87 | ` |
83 | 88 |
|
@@ -197,6 +202,16 @@ code |
197 | 202 | .white |
198 | 203 | color: #A6ACCD |
199 | 204 |
|
| 205 | +.warning |
| 206 | + background-color: #FECDD3 |
| 207 | + border-radius: $border-radius |
| 208 | + color: #881337 |
| 209 | + margin: 20px |
| 210 | + padding: 0.1px |
| 211 | +
|
| 212 | + h2 |
| 213 | + color: #9F1239 |
| 214 | +
|
200 | 215 | footer |
201 | 216 | background-color: $brand-primary |
202 | 217 | border-radius: $border-radius |
|
0 commit comments