Skip to content

Commit

Permalink
say8425#4 add the possibility to define xss options
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Tempel committed Jul 18, 2022
1 parent 9b608af commit 7b2ff56
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ app.mount('#app')

You can use the [linkify options](https://linkify.js.org/docs/options.html).

### Define XSS Options

```vue
<template>
<div v-linkify:options="{
xssOptions: {
whiteList: {
span: ['style'],
}
},
}">
...
</div>
</template>
```

You can use the [xss options](https://jsxss.com/en/options#customize-whitelist).

### Add event listener

```vue
Expand Down
10 changes: 7 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { App, Directive } from "@vue/runtime-core";
import linkifyHtml from "linkify-html";
import { Options } from "linkifyjs";
import xss from "xss";
import xss, { IFilterXSSOptions } from "xss";

const linkify = (rawHtml: string, options: Options): string => {
const sanitized = xss(rawHtml);
interface VueLinkifyOptions extends Options {
xssOptions?: IFilterXSSOptions;
}

const linkify = (rawHtml: string, options: VueLinkifyOptions): string => {
const sanitized = xss(rawHtml, options.xssOptions);
return linkifyHtml(sanitized, options);
};

Expand Down

0 comments on commit 7b2ff56

Please sign in to comment.