<%= select_tag "select_name", options_for_select(@name_select_list.collect{|p| [p["name"], p["id"]]}), :style => "width:200px", :prompt => I18n.t('labels.items.all') %>
p["name"] = " alert(9999)"
期待値:下拉菜单里显示
” <script>alert(9999)</script>”
対策案:
①<%= select_tag "select_name", options_for_select(@name_select_list.collect{|p| [(sanitize p["name"]), p["id"]]}), :style => "width:200px", :prompt => I18n.t('labels.items.all') %>
結果:下拉菜单里显示
” alert(9999)”
②<%= select_tag "select_name", options_for_select(@name_select_list.collect{|p| [p["name"], p["id"]]}), :style => "width:200px", :prompt => I18n.t('labels.items.all') %>
結果:下拉菜单里显示
” <script>alert(9999)</script>”
有能完美解决的方案吗?