<commit_before>class HaisyoListener < AsakusaSatellite::Hook::Listener
  def message_buttons(context)
    message = truncate(context[:message].body.gsub(/\r\n|\r|\n|\t/," "))

js_code = <<JSCODE
$(function() {
  $('#message').val('拝承。 ＞ #{message}');
  $('.inputarea').submit();
});
JSCODE

    return <<HTML
<img src="/plugin/as_haisyo/image/haisyo.png" onClick="#{js_code}" alt="拝承。">
HTML
  end
end
<commit_msg>* JSコードの埋め込みを防ぐため拝承メッセージをdata属性へ移動 * XSSを防ぐためhtml_escapeを追加<commit_after>class HaisyoListener < AsakusaSatellite::Hook::Listener
  def message_buttons(context)
    message = truncate(context[:message].body.gsub(/\r\n|\r|\n|\t/," "))

js_code = <<JSCODE
(function(message) {
  $('#message').val('拝承。 ＞ ' + message + '');
  $('.inputarea').submit();
})($(this).data('haisyo'));
JSCODE

    return <<HTML
<img src="/plugin/as_haisyo/image/haisyo.png" data-haisyo="#{ERB::Util.html_escape message}" onClick="#{js_code}" alt="拝承。">
HTML
  end
end

{'fraction_non_alphanumeric': 0.2175732217573222, 'fraction_numerical': 0.0, 'mean_word_length': 5.6923076923076925, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '399131', 'n_tokens_mistral': 406, 'n_tokens_neox': 407, 'n_words': 51}