mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2024-10-07 03:23:37 +00:00
feat(htmlhelper): unescape the input and strip all tags except br
This commit is contained in:
parent
8ec9276a18
commit
2ddb650d88
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
|
import { decode } from 'he';
|
||||||
|
|
||||||
declare module '@nuxt/types' {
|
declare module '@nuxt/types' {
|
||||||
interface Context {
|
interface Context {
|
||||||
@ -32,8 +33,11 @@ const htmlHelper = Vue.extend({
|
|||||||
*/
|
*/
|
||||||
sanitizeHtml(input: string): string {
|
sanitizeHtml(input: string): string {
|
||||||
// Some providers have newlines, replace them with the proper tag.
|
// Some providers have newlines, replace them with the proper tag.
|
||||||
let cleanString = input.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
let cleanString = decode(input).replace(/(?:\r\n|\r|\n)/g, '<br>');
|
||||||
cleanString = DOMPurify.sanitize(cleanString);
|
cleanString = DOMPurify.sanitize(cleanString, {
|
||||||
|
ALLOWED_TAGS: ['br', 'b', 'strong', 'i', 'em'],
|
||||||
|
KEEP_CONTENT: true
|
||||||
|
});
|
||||||
return cleanString;
|
return cleanString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
"date-fns": "^2.17.0",
|
"date-fns": "^2.17.0",
|
||||||
"dompurify": "^2.2.6",
|
"dompurify": "^2.2.6",
|
||||||
"entities": "^2.2.0",
|
"entities": "^2.2.0",
|
||||||
|
"he": "^1.2.0",
|
||||||
"js-cookie": "^2.2.1",
|
"js-cookie": "^2.2.1",
|
||||||
"langs": "^2.0.0",
|
"langs": "^2.0.0",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
@ -72,6 +73,7 @@
|
|||||||
"@nuxtjs/vuetify": "^1.11.3",
|
"@nuxtjs/vuetify": "^1.11.3",
|
||||||
"@types/cookie": "^0.4.0",
|
"@types/cookie": "^0.4.0",
|
||||||
"@types/dompurify": "^2.2.1",
|
"@types/dompurify": "^2.2.1",
|
||||||
|
"@types/he": "^1.1.1",
|
||||||
"@types/jest": "^26.0.20",
|
"@types/jest": "^26.0.20",
|
||||||
"@types/js-cookie": "^2.2.6",
|
"@types/js-cookie": "^2.2.6",
|
||||||
"@types/lodash": "^4.14.168",
|
"@types/lodash": "^4.14.168",
|
||||||
|
@ -2150,6 +2150,11 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/he@^1.1.1":
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.npmjs.org/@types/he/-/he-1.1.1.tgz#19e14033c4ee8f1a702c74dcc6182664839ac2b7"
|
||||||
|
integrity sha512-jpzrsR1ns0n3kyWt92QfOUQhIuJGQ9+QGa7M62rO6toe98woQjnsnzjdMtsQXCdvjjmqjS2ZBCC7xKw0cdzU+Q==
|
||||||
|
|
||||||
"@types/html-minifier-terser@^5.0.0":
|
"@types/html-minifier-terser@^5.0.0":
|
||||||
version "5.1.1"
|
version "5.1.1"
|
||||||
resolved "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz#3c9ee980f1a10d6021ae6632ca3e79ca2ec4fb50"
|
resolved "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz#3c9ee980f1a10d6021ae6632ca3e79ca2ec4fb50"
|
||||||
|
Loading…
Reference in New Issue
Block a user