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 forwards in the filter chain #429

Merged
merged 1 commit into from
Nov 27, 2022
Merged
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
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