Sha256: e36826eaee475a20e96bc201941b07996508181b2ee90b7412b2e93f9a41cea7
Contents?: true
Size: 475 Bytes
Versions: 18
Compression:
Stored size: 475 Bytes
Contents
module Zafu module Security SECURE_REGEXP = %r{<%|%>|<\Z} SAFE_CODE = {'<%' => '<%', '%>' => '%>', '<' => '<'} # Make sure translations and other literal values cannot be used to build erb. def erb_escape(text) # Do not only replace '<%' ! or <r:t>min</r:t>% ==> <% ... text.gsub(SECURE_REGEXP) {|code| SAFE_CODE[code]} end def form_quote(text) erb_escape(text).gsub("'", "'") end end # Security end # Zafu
Version data entries
18 entries across 18 versions & 2 rubygems