widget: unrestrict html property (yes, let users break the app eventually), speeds up build times 2x
This commit is contained in:
parent
4696275047
commit
4e4481cf96
4 changed files with 7 additions and 24 deletions
|
|
@ -5,6 +5,10 @@
|
|||
- bug fixes
|
||||
- server: fix resolving absolute file urls containing the remote-root path
|
||||
|
||||
- widgets
|
||||
- the html property is no longer restricted / sanitized
|
||||
|
||||
|
||||
|
||||
## 1.29.8
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@
|
|||
"rollup-plugin-copy": "3.5.0",
|
||||
"rollup-plugin-license": "^3.6.0",
|
||||
"rollup-plugin-node-externals": "^8.1.1",
|
||||
"sanitize-html": "1.27.5",
|
||||
"sass": "1.89.2",
|
||||
"scope-css": "1.2.1",
|
||||
"screenfull": "5.2.0",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ var EventEmitter = require('../../events/event-emitter'),
|
|||
{deepCopy, deepEqual, isJSON} = require('../../utils'),
|
||||
html = require('nanohtml/lib/browser'),
|
||||
morph = require('nanomorph'),
|
||||
sanitizeHtml = require('sanitize-html'),
|
||||
updateWidget = ()=>{},
|
||||
Script = require('../scripts/script'),
|
||||
uiConsole, uiTree, uiDragResize, sessionManager
|
||||
|
|
@ -82,13 +81,7 @@ class Widget extends EventEmitter {
|
|||
html: {type: 'string', value: '', editor: 'html', syntaxChecker: false, help: [
|
||||
'Custom html content to be inserted in the widget (before the widget\'s content). Elements are all unstyled by default, `css` should be used to customize their appearance.',
|
||||
'The code is automatically wrapped in <div class="html"></div>',
|
||||
'Allowed HTML tags:',
|
||||
' h1-6, blockquote, p, a, ul, ol, nl, li,',
|
||||
' b, i, strong, em, strike, code, hr, br, div,',
|
||||
' table, thead, img, caption, tbody, tr, th, td, pre',
|
||||
'Allowed attributes:',
|
||||
' <*>: class, style, title, name',
|
||||
' <img>: src, width, height',
|
||||
'Note: inserting scripts may break the application.',
|
||||
]},
|
||||
css: {type: 'string', value: '', editor: 'css', syntaxChecker: false, help: [
|
||||
'CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.',
|
||||
|
|
@ -1278,7 +1271,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
updateHtml(){
|
||||
|
||||
var extraHtml = this.getProp('html') !== '' ? sanitizeHtml(this.getProp('html'), Widget.sanitizeHtmlOptions) : null
|
||||
var extraHtml = this.getProp('html') || null
|
||||
|
||||
if (this.extraHtml) {
|
||||
if (!extraHtml) {
|
||||
|
|
@ -1346,18 +1339,6 @@ class Widget extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
Widget.sanitizeHtmlOptions = {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2']).filter(x=>x!=='iframe'),
|
||||
allowedAttributes: {
|
||||
'*': [ 'title', 'class', 'style', 'name'],
|
||||
'img': [ 'src' , 'title', 'class', 'style', 'width', 'height'],
|
||||
'a': ['href', 'target']
|
||||
},
|
||||
transformTags: {
|
||||
'a': sanitizeHtml.simpleTransform('a', {target: '_blank'})
|
||||
}
|
||||
}
|
||||
|
||||
Widget.parsersContexts = {}
|
||||
|
||||
Widget.cssVariables = [
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
var Widget = require('../common/widget'),
|
||||
morph = require('nanomorph'),
|
||||
html = require('nanohtml/lib/browser'),
|
||||
sanitizeHtml = require('sanitize-html'),
|
||||
StaticProperties = require('../mixins/static_properties')
|
||||
|
||||
class Html extends StaticProperties(Widget, {bypass: true}) {
|
||||
|
|
@ -49,7 +48,7 @@ class Html extends StaticProperties(Widget, {bypass: true}) {
|
|||
|
||||
var newHtml = this.frame.cloneNode(false)
|
||||
|
||||
newHtml.innerHTML = sanitizeHtml(this.getProp('html'), Widget.sanitizeHtmlOptions)
|
||||
newHtml.innerHTML = this.getProp('html')
|
||||
|
||||
morph(this.frame, newHtml)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue