Skip to content

Commit 692f159

Browse files
committed
Making Haml escape by defualt.
I love using Haml's :escape_html option to help catch all of those XSS attacks!
1 parent a028b22 commit 692f159

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

configure.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
set :views, File.join(File.dirname(__FILE__), 'views')
22

3+
set :haml, :escape_html => true
4+
35
def setup_db environ
46
MongoMapper.connection = Mongo::Connection.new('localhost')
57
MongoMapper.database = "hackety-#{environ}"

views/layout.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
%a{:href => "/login" }Log in
1313
%div{:id => "flash-notice"}= flash[:notice]
1414
%div{:id => "flash-error"}= flash[:error]
15-
= yield
15+
!= yield

views/posts/show.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%h1= @post.title
22
- markdown = RDiscount.new(@post.body, :smart, :filter_html)
3-
%p= markdown.to_html
3+
%p!= markdown.to_html
44

55
%hr
66

0 commit comments

Comments
 (0)