I am in a rails app building a string of html to send to a third party email service such as the below:
table_html = ""
@tickets.each do |ticket|
table_html << "<tr>"
table_html << "<td> #{ticket.number} </td>"
table_html << "<td>#{ticket.section_name} - #{ticket.row_name} </td>"
table_html << "</tr>"
end
I was told by a colleague to always escape html entities when constructing html like this because of the risk of an injection attack. I understand the basics of an injection attack, but could someone explain how escaping lowers that risk, and what I should use to escape? Was looking into using haml. Thanks!