1
0

More than 5 years have passed since last update.

js.erbファイルにコメントを書くときは//を使わない

Posted at

修正前

index.js.erb
// コメントが見えてるよ!
$("#ajax_panel").html("<%= escape_javascript(render partial: "ajax_panel") %>");

結果

ツールを使ってファイルを見ると...
(画像はChromeのデベロッパーツールのNetworkパネルから確認)
スクリーンショット 2019-05-24 14.01.35.png

コメントに重要な内容が含まれていると、敵の攻撃を手助けしてしまう可能性があり危険です。

修正

erbファイルのコメントの書き方に修正します。

index.js.erb
<%# コメントが見えないだと... %>
$("#ajax_panel").html("<%= escape_javascript(render partial: "ajax_panel") %>");

修正後

コメントが表示されなくなりました。
スクリーンショット 2019-05-24 14.04.56.png

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