From 9f5fff12251acf8dbe1bf4cc74dab830ada9c4e8 Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 28 Aug 2005 14:20:42 +0000 Subject: [PATCH] Added the sanitize method to all of the fields which get displayed on the page (context.name, project.name, project.description, todo.description, todo.notes, note.body). This stops harmful HTML codes being embedded in the page. Sanitize strips out javascript and on* attributes. The HTML gets rendered with the HTML entities escaped. Incidentally, #79 does seem to be fixed now: if you enter a project or context name with a slash, the slash is escaped in the URL as %2F, so links don't break. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@142 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/views/context/_context_listing.rhtml | 2 +- tracks/app/views/context/_show_items.rhtml | 8 ++++---- tracks/app/views/context/list.rhtml | 2 +- tracks/app/views/context/show.rhtml | 6 +++--- tracks/app/views/note/_notes.rhtml | 2 +- tracks/app/views/note/_notes_summary.rhtml | 2 +- tracks/app/views/project/_project_listing.rhtml | 2 +- tracks/app/views/project/_show_items.rhtml | 8 ++++---- tracks/app/views/project/show.rhtml | 4 ++-- tracks/app/views/shared/add_new_item_form.rhtml | 4 ++-- tracks/app/views/shared/sidebar.rhtml | 8 ++++---- tracks/app/views/todo/_action_edit_form.rhtml | 4 ++-- tracks/app/views/todo/_done.rhtml | 4 ++-- tracks/app/views/todo/_item.rhtml | 4 ++-- tracks/app/views/todo/list.rhtml | 2 +- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tracks/app/views/context/_context_listing.rhtml b/tracks/app/views/context/_context_listing.rhtml index f5cfa0d5..82863e6c 100644 --- a/tracks/app/views/context/_context_listing.rhtml +++ b/tracks/app/views/context/_context_listing.rhtml @@ -18,7 +18,7 @@ {:action => "move_bottom", :id => context.id}, :title => "Move to bottom", :class=>"to_bottom") %>
- <%= link_to( "#{context.name}", :action => "show", :name => urlize(context.name) ) %> + <%= link_to( sanitize("#{context.name}"), :action => "show", :name => urlize(context.name) ) %> <%= " (" + context.count_undone_todos("actions") + ")" %>
diff --git a/tracks/app/views/context/_show_items.rhtml b/tracks/app/views/context/_show_items.rhtml index 80f8b335..306a5959 100644 --- a/tracks/app/views/context/_show_items.rhtml +++ b/tracks/app/views/context/_show_items.rhtml @@ -31,13 +31,13 @@ <%= staleness( item ) %> <% end %> <%= due_date( item.due ) %> - <%= item.description %> + <%= sanitize(item.description) %> <% if item.project_id %> <%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %> <% end %> <% if item.notes? %> <%= "" + image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "" %> - <% m_notes = markdown( item.notes ) %> + <% m_notes = sanitize(markdown( item.notes )) %> <%= "
" + m_notes + "
" %> <% end %> @@ -81,13 +81,13 @@
<%= format_date( item.completed ) %> - <%= item.description %> + <%= sanitize(item.description) %> <% if item.project_id %> <%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %> <% end %> <% if item.notes? %> <%= "" + image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "" %> - <% m_notes = markdown( item.notes ) %> + <% m_notes = sanitize(markdown( item.notes )) %> <%= "
" + m_notes + "
" %> <% end %>
diff --git a/tracks/app/views/context/list.rhtml b/tracks/app/views/context/list.rhtml index 3ecce4cf..4fbae559 100644 --- a/tracks/app/views/context/list.rhtml +++ b/tracks/app/views/context/list.rhtml @@ -33,4 +33,4 @@
<%= @flash["warning"] %>
<% end %> - \ No newline at end of file + \ No newline at end of file diff --git a/tracks/app/views/context/show.rhtml b/tracks/app/views/context/show.rhtml index 7c2f01bf..78bfc8fb 100644 --- a/tracks/app/views/context/show.rhtml +++ b/tracks/app/views/context/show.rhtml @@ -1,7 +1,7 @@
-

<%= @context.name %>

+

<%= sanitize(@context.name) %>

<% if @not_done.empty? %> @@ -44,9 +44,9 @@ :html=> { :id=>'context-form-new-action', :name=>'context', :class => 'inline-form' } %> <%= hidden_field( "new_item", "context_id", "value" => "#{@context.id}") %>
- <%= text_field( "new_item", "description", "size" => 25, "tabindex" => 1 ) %>
+ <%= text_field( "new_item", "description", "size" => 25, "tabindex" => 1) %>

- <%= text_area( "new_item", "notes", "cols" => 25, "rows" => 10, "tabindex" => 2 ) %>
+ <%= text_area( "new_item", "notes", "cols" => 25, "rows" => 10, "tabindex" => 2) %>