16177: Use correct config item Collections.TrustAllContent
authorPeter Amstutz <peter.amstutz@curii.com>
Wed, 26 Feb 2020 20:31:58 +0000 (15:31 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Mon, 2 Mar 2020 22:31:06 +0000 (17:31 -0500)
Also added fallback error handler, if view or download link doesn't
work, render error text (otherwise you get a very confusing Rails
crash page).

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/views/application/error.text.erb [new file with mode: 0644]

index 5407700615c4fb7b7125e814fa1811001a809efd..8d6f897bb69b1770054d15337cb28cb6bf507876 100644 (file)
@@ -62,6 +62,7 @@ class ApplicationController < ActionController::Base
       # the browser can't.
       f.json { render opts.merge(json: {success: false, errors: @errors}) }
       f.html { render({action: 'error'}.merge(opts)) }
+      f.all { render({action: 'error', formats: 'text'}.merge(opts)) }
     end
   end
 
index 10e026ae6c80578e9cd9c933cbb188bd57f1ca94..9073d06c178c3edeb23bee3b3d16cfcafca5f4ff 100644 (file)
@@ -343,7 +343,7 @@ class CollectionsController < ApplicationController
       # Prefer the attachment-only-host when we want an attachment
       # (and when there is no preview link configured)
       tmpl = Rails.configuration.Services.WebDAVDownload.ExternalURL.to_s
-    elsif not Rails.configuration.Workbench.TrustAllContent
+    elsif not Rails.configuration.Collections.TrustAllContent
       check_uri = URI.parse(tmpl.sub("*", munged_id))
       if opts[:query_token] and
         (check_uri.host.nil? or (
diff --git a/apps/workbench/app/views/application/error.text.erb b/apps/workbench/app/views/application/error.text.erb
new file mode 100644 (file)
index 0000000..1035182
--- /dev/null
@@ -0,0 +1,11 @@
+<%# Copyright (C) The Arvados Authors. All rights reserved.
+
+SPDX-License-Identifier: AGPL-3.0 %>
+
+Oh... fiddlesticks.
+
+Sorry, I had some trouble handling your request.
+
+<% if @errors.is_a? Array then @errors.each do |error| %>
+<%= error %>
+<% end end %>