Skip to content

Commit

Permalink
fix xss vulnerability in mathjax parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Apr 12, 2011
1 parent d3594f6 commit 17dcde1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/gollum/markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ def doc_to_html(doc)
# Returns the placeholder'd String data.
def extract_tex(data)
data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do
id = Digest::SHA1.hexdigest($1)
@texmap[id] = [:block, $1]
tag = CGI.escapeHTML($1)
id = Digest::SHA1.hexdigest(tag)
@texmap[id] = [:block, tag]
id
end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do
id = Digest::SHA1.hexdigest($1)
@texmap[id] = [:inline, $1]
tag = CGI.escapeHTML($1)
id = Digest::SHA1.hexdigest(tag)
@texmap[id] = [:inline, tag]
id
end
end
Expand Down

0 comments on commit 17dcde1

Please sign in to comment.