Skip to content

Commit

Permalink
Changed HTML encoder evil char handling (allowing for UTF-8 now.)
Browse files Browse the repository at this point in the history
  • Loading branch information
korny committed Mar 16, 2006
1 parent ace3fce commit f8c4a4b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/coderay/encoders/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ def initialize(*)
'<' => '&lt;',
}

# This is to prevent illegal HTML.
# This was to prevent illegal HTML.
# Strange chars should still be avoided in codes.
evil_chars = Array(0x00...0x20) - [?n, ?t]
evil_chars = Array(0x00...0x20) - [?\n, ?\t, ?\s]
evil_chars.each { |i| HTML_ESCAPE[i.chr] = ' ' }
ansi_chars = Array(0x7f..0xff)
ansi_chars.each { |i| HTML_ESCAPE[i.chr] = '&#%d;' % i }
#ansi_chars = Array(0x7f..0xff)
#ansi_chars.each { |i| HTML_ESCAPE[i.chr] = '&#%d;' % i }
# \x9 (\t) and \xA (\n) not included
HTML_ESCAPE_PATTERN = /[\t&"><\xB-\x1f\x7f-\xff\0-\x8]/
#HTML_ESCAPE_PATTERN = /[\t&"><\0-\x8\xB-\x1f\x7f-\xff]/
HTML_ESCAPE_PATTERN = /[\t"&><\0-\x8\xB-\x1f]/

TOKEN_KIND_TO_INFO = Hash.new { |h, kind|
h[kind] =
Expand Down

0 comments on commit f8c4a4b

Please sign in to comment.