LoginSignup
5
5

More than 5 years have passed since last update.

Chrome+WYSIWYGエディタで動画を埋め込むと空白で表示される

Last updated at Posted at 2015-11-10

フォーム入力にエディタ(tinyMCE)を使用しており、動画を埋め込むことができるのだが、確認画面で動画が再生されず、空白として表示される

コンソールを見ると以下のエラーが出ていた

The XSS Auditor refused to execute a script in 'http://hoge.com/foo/bar' because its source code was found within the request. The auditor was enabled as the server sent neither an 'X-XSS-Protection' nor 'Content-Security-Policy' header.

ブラウザの仕様でフォームPOST時にXSS対策をしており、そのチェックにひっかかっているよう(Chrome, Safariのみ再現)

対策として

  • XSSチェックをオフするヘッダを出力する
  • formタグのactionの要素をシングルクォーテーションで囲む

の2つがあるが、後者は微妙.

フレームワークを使用していたこと、また該当ページにおいて別ロジックでユーザー判定をしていたため、XSSチェックはいらないので前者をとる

CakePHPの例


    function hoge() {
            // POSTできた場合
            if($this->data){
                $this->header('X-XSS-Protection: 0');
                //以下何らかの処理
            }
    }

参考:
http://qiita.com/mimoe/items/e43445dc8bb214e1906a
http://gqevu6bsiz.chicappa.jp/google-chrome-%E3%81%AExss%E4%BB%95%E6%A7%98%E3%81%AB%E3%81%AF%E3%81%BE%E3%82%8B%E3%80%82/

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5