Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Sanitize filter further to front of filter chain, don't sanitize Macros seperately #428

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,3 @@ task :changelog do
`cat #{history_file} >> #{temp.path}`
`cat #{temp.path} > #{history_file}`
end

desc 'Precompile assets'
task :precompile do
require './lib/gollum/app.rb'
Precious::App.set(:environment, :production)
env = Precious::Assets.sprockets
path = ENV.fetch('GOLLUM_ASSETS_PATH', ::File.join(File.dirname(__FILE__), 'lib/gollum/public/assets'))
manifest = Sprockets::Manifest.new(env, path)
Sprockets::Helpers.configure do |config|
config.environment = env
config.prefix = Precious::Assets::ASSET_URL
config.digest = true
config.public_path = path
config.manifest = manifest
end
puts "Precompiling assets to #{path}..."
manifest.compile(Precious::Assets::MANIFEST)
end
2 changes: 1 addition & 1 deletion lib/gollum-lib/filter/macro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def process(data)
end
end

sanitize(data)
data
end
end
2 changes: 1 addition & 1 deletion lib/gollum-lib/wiki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def initialize(path, options = {})
@per_page_uploads = options.fetch :per_page_uploads, false
@metadata = options.fetch :metadata, {}
@filter_chain = options.fetch :filter_chain,
[:YAML, :BibTeX, :PlainText, :CriticMarkup, :TOC, :RemoteCode, :Code, :Macro, :Emoji, :Sanitize, :PlantUML, :Tags, :PandocBib, :Render]
[:YAML, :BibTeX, :PlainText, :CriticMarkup, :TOC, :Sanitize, :RemoteCode, :Code, :Macro, :Emoji, :PlantUML, :Tags, :PandocBib, :Render]
@filter_chain.delete(:Emoji) unless options.fetch :emoji, false
@filter_chain.delete(:PandocBib) unless ::Gollum::MarkupRegisterUtils.using_pandoc?
@filter_chain.delete(:CriticMarkup) unless options.fetch :critic_markup, false
Expand Down
2 changes: 1 addition & 1 deletion test/test_macros.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def render(opts)
assert_match /<div class=\"flash flash-error\"><svg.*class=\"octicon octicon-zap mr-2\".*Macro Error for Octicon: Couldn't find octicon symbol for "foobar".*/, @wiki.pages[0].formatted_data
end

test "Audio macro escapes HTML" do
test "Macros escape HTML" do
@wiki.write_page("AudioXSSTest", :markdown, '<<Audio(a"></audio><input>)>>', commit_details)
assert_not_match /<input/, @wiki.pages[0].formatted_data
end
Expand Down