LoginSignup
0
0

More than 3 years have passed since last update.

scriptタグ内の / がエスケープされる(CakePHP + minify-html + Underscore.js)

Posted at

起きたこと

composer updateをしたらUnderscore.jsのテンプレート機能で表示しているhtmlに意図しない文字列が表示されるようになった。
ブラウザに表示されたhtmlのコードを確認したところ、<script>内の終了タグで使われている/がエスケープされていた。

inedex.php
<script type="text/template" id="template">
  <div data-id="<%= id %>">
      <%= name %>
  <\/div> //タグとして認識されずにそのまま画面に表示される
</script>

原因

wyrihaximus/minify-htmlライブラリがrequireしているwyrihaximus/html-compress2.0.1の不具合または仕様。

対策方法

minify-htmlのバージョンを1.4系にする。
composer.jsonに以下を記載。

composer.json
{
  "require": {
    "wyrihaximus/html-compress": "1.4.*",
  },

composer updateして更新。

最後に

同じ環境の方はほとんどいないと思いますが、調べても情報が出てこなかったので書き残しておきます。

0
0
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
0
0