diff --git a/bin/gollum b/bin/gollum index 1880c175..e28e37f5 100755 --- a/bin/gollum +++ b/bin/gollum @@ -134,6 +134,7 @@ MSG opts.on("--mathjax", "Enable MathJax (renders mathematical equations).", "By default, uses the 'TeX-AMS-MML_HTMLorMML' config with the 'autoload-all' extension.") do wiki_options[:mathjax] = true + wiki_options[:mathjax_config] = 'mathjax.config.js' end opts.on("--critic-markup", "Enable support for annotations using CriticMarkup.") do wiki_options[:critic_markup] = true @@ -155,10 +156,6 @@ MSG "Can be set to 'gravatar', 'identicon' or 'none'. Default: 'none'.") do |mode| wiki_options[:user_icons] = mode end - opts.on("--mathjax-config [FILE]", "Specify path to a custom MathJax configuration.", - "If not specified, uses the '/mathjax.config.js' file.") do |file| - wiki_options[:mathjax_config] = file || 'mathjax.config.js' - end opts.on("--template-dir [PATH]", "Specify custom mustache template directory.") do |path| wiki_options[:template_dir] = path end diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 22c2908f..e2caa6ec 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -152,15 +152,15 @@ module Precious end end - get %r{/(edit|create)/custom\.(js|css)} do + get %r{/(edit|create)/(custom|mathjax\.config)\.(js|css)} do forbid('Changing this resource is not allowed.') end - post %r{/(delete|rename|edit|create)/custom\.(js|css)} do + post %r{/(delete|rename|edit|create)/(custom|mathjax\.config)\.(js|css)} do forbid('Changing this resource is not allowed.') end - post %r{/revert/custom\.(js|css)/.*/.*} do + post %r{/revert/(custom|mathjax\.config\.)\.(js|css)/.*/.*} do forbid('Changing this resource is not allowed.') end diff --git a/test/test_app.rb b/test/test_app.rb index 27e0ecf2..e4832283 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -54,7 +54,7 @@ context "Frontend" do { :name => 'user1', :email => 'user1' }); get page - expected = "

#{text}

" + expected = "

#{text}

" actual = nfd(last_response.body) assert_match /#{expected}/, actual @@ -524,6 +524,8 @@ context "Frontend" do get "/gollum/#{route}/custom#{ext}" assert_equal 403, last_response.status, "get /gollum/#{route}/custom#{ext} -- #{last_response.inspect}" end + get "/gollum/#{route}/mathjax.config.js" + assert_equal 403, last_response.status, "get /gollum/#{route}/mathjax.config.js -- #{last_response.inspect}" end ['delete', 'rename', 'edit', 'create'].each do |route| @@ -531,6 +533,8 @@ context "Frontend" do post "/gollum/#{route}/custom#{ext}" assert_equal 403, last_response.status, "post /gollum/#{route}/custom#{ext} -- #{last_response.inspect}" end + post "/gollum/#{route}/mathjax.config.js" + assert_equal 403, last_response.status, "post /gollum/#{route}/mathjax.config.js -- #{last_response.inspect}" end ['.css', '.js'].each do |ext|