lincanbin / Carbon-Forum

A high performance open-source forum software written in PHP. Discussions Tags based with Quora/StackOverflow style.
https://www.94cb.com/
Apache License 2.0
1.84k stars 434 forks source link

embed iframe object HTML tag NOT working? 编辑器嵌入iframe object #287

Open hoogw opened 5 years ago

hoogw commented 5 years ago

I try to embed a iframe in editor. but it would not save to database.

If I close it, then re-open the post, the html iframe is missing.

Do you know why? How to fix it?

I try to embed <object type="text/html" data="http://j2t.transparentgov.net/folder.html?url=https://geodata.epa.gov/arcgis/rest/services"width="600"height="600"></object>

<object type="text/html" data="http://j2t.transparentgov.net/folder.html?url=https://geodata.epa.gov/arcgis/rest/services" width="600" height="600"

hoogw commented 5 years ago

I found solution. 2 steps.

1) 添加你的iframe src 域名到白名单过滤器 C:\Apache24\htdocs\glassgov1\common.php

open common.php, search "iframe", add your iframe src domain to white filter.

I add **'j2t.transparentgov.net', 'transparentgov.net', 'www.transparentgov.net',
            'ms1.transparentgov.net',**   

 to  **$hostWhiteList**

//跨站脚本白名单过滤 function XssEscape($html) { $filter = new WhiteHTMLFilter(); $urlFilter = function($url) { $token = parse_url($url); if (empty($token['scheme']) || in_array($token['scheme'], array('http', 'https')) === false) { return ''; } $hostWhiteList = array( 'j2t.transparentgov.net', 'transparentgov.net', 'www.transparentgov.net', 'ms1.transparentgov.net', 'www.youtube.com', 'youtube.com', 'www.youtu.be', 'youtu.be', 'player.youku.com', 'v.youku.com',

2)ueditor config 添加 iframe 元素,object 元素。 C:\Apache24\htdocs\glassgov1\static\editor\ueditor.config.js

Open ueditor.config.js, add below 3 line code at : window.UEDITOR_CONFIG = { )

            // allow embed iframe tag
            ,iframe: ['frameborder','src','width','height']
            ,object: ['type','data','width','height']

// allow embed iframe tag ,iframe: ['frameborder','src','width','height'] ,object: ['type','data','width','height']

Success embed iframe, object html tag

asleep2 commented 5 years ago

@hoogw nginx呢?怎么操作