From 006dd36078bbefd8a0dd883cbbb9f1f1cc4e989b Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Fri, 28 Dec 2018 22:07:07 +0100 Subject: [PATCH 1/3] Make mathjax.config.js the standard filename. Fixes #1340. --- bin/gollum | 5 +---- lib/gollum/app.rb | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) 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..88bc9ce2 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 From 59bb48340e174f9e80733c4fc3284293c7ccc5c6 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Fri, 28 Dec 2018 22:45:17 +0100 Subject: [PATCH 2/3] Fix test by adding new h2 editable class to expected output. --- test/test_app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_app.rb b/test/test_app.rb index 27e0ecf2..6c89c485 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 From e966de69222abe650ec5e62fc0ebeb84270b24f5 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Fri, 28 Dec 2018 22:57:13 +0100 Subject: [PATCH 3/3] Added tests for mathjax.config.js permissions. Fixed typo in permission regex. --- lib/gollum/app.rb | 4 ++-- test/test_app.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 88bc9ce2..e2caa6ec 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -152,11 +152,11 @@ module Precious end end - get %r{/(edit|create)/(custom|mathjax\.config\.)\.(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|mathjax\.config\.)\.(js|css)} do + post %r{/(delete|rename|edit|create)/(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 6c89c485..e4832283 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -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|