Skip to content

Commit

Permalink
Allow youtube iframes (resolves #31)
Browse files Browse the repository at this point in the history
  • Loading branch information
luxaritas committed Jun 8, 2020
1 parent beecf32 commit dfcfb6b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.13.0",
"@johmun/vue-tags-input": "^2.1.0",
"@types/dompurify": "^2.0.2",
"@types/lodash": "^4.14.151",
"@types/nightwatch": "^1.1.4",
"@types/swiper": "^5.3.1",
Expand All @@ -28,6 +29,7 @@
"canvas": "^2.6.1",
"chromedriver": "^81.0.0",
"core-js": "^3.6.5",
"dompurify": "^2.0.11",
"dotenv": "^8.2.0",
"eslint-config-prettier": "^6.11.0",
"eterna-chat-wrapper": "github:eternagame/eterna-chat-wrapper",
Expand Down
14 changes: 13 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@ import i18n from '@/plugins/i18n';
import { sync } from 'vuex-router-sync';
import BootstrapVue from 'bootstrap-vue';
import VueDOMPurifyHTML from 'vue-dompurify-html';
import DOMPurify from 'dompurify';
import axios from 'axios';
import InitGlobalComponents from '@/components/global';
import App from './App.vue';
import createRouter from './router';
import createStore from './store/store';

Vue.use(BootstrapVue);
Vue.use(VueDOMPurifyHTML);
Vue.use(VueDOMPurifyHTML, {
default: {
ADD_TAGS: ['iframe']
}
});

DOMPurify.addHook('uponSanitizeElement', (node, data) => {
if (data.tagName === 'iframe') {
const validSrc = (node as HTMLIFrameElement).src.match(/^(https:)?\/\/(www.)?(youtube.com)\/.*$/);
if (!validSrc) node.remove();
}
});

// Types for properties added to Vue (prototype) are in types/vue.d.ts
// Make sure to update that if you change what is included here!
Expand Down

0 comments on commit dfcfb6b

Please sign in to comment.