NoParse class removed

This commit is contained in:
Karel Picman 2016-05-02 10:31:43 +02:00
parent 542b9aa217
commit 39f3a92e46
3 changed files with 1 additions and 51 deletions

View File

@ -110,8 +110,7 @@ RedmineApp::Application.routes.draw do
get '/dmsf/folders/:id/copy', :controller => 'dmsf_folders_copy', :action => 'new', :as => 'copy_folder'
#
# DAV4Rack implementation of Webdav [note: if changing path you'll need to update lib/redmine_dmsf/webdav/no_parse.rb also]
# /dmsf/webdav
# DAV4Rack implementation of Webdav
mount DAV4Rack::Handler.new(
:root_uri_path => "#{Redmine::Utils::relative_url_root}/dmsf/webdav",
:resource_class => RedmineDmsf::Webdav::ResourceProxy,

View File

@ -32,7 +32,6 @@ require 'redmine_dmsf/patches/project_tabs_extended'
require 'redmine_dmsf/patches/user_preference_patch'
# Load up classes that make up our WebDAV solution ontop of DAV4Rack
require 'redmine_dmsf/webdav/no_parse'
require 'redmine_dmsf/webdav/base_resource'
require 'redmine_dmsf/webdav/controller'
require 'redmine_dmsf/webdav/dmsf_resource'

View File

@ -1,48 +0,0 @@
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module RedmineDmsf
class NoParse
def initialize(app, options={})
@app = app
@urls = options[:urls]
end
def call(env)
if env['REQUEST_METHOD'] == 'PUT' && env.has_key?('CONTENT_TYPE') then
if (@urls.dup.delete_if {|x| !env['PATH_INFO'].starts_with? x}.length > 0) then
Rails.logger.info "RedmineDmsf::NoParse prevented mime parsing for PUT #{env['PATH_INFO']}"
env['CONTENT_TYPE'] = 'text/plain'
end
end
@app.call(env)
end
end
end
# Todo:
# This should probably be configurable somehow or better have the module hunt for the correct pathing
# automatically without the need to add a "/dmsf/webdav" configuration to it, as if the route is changed
# the functonality of this patch will effectively break.
Rails.configuration.middleware.insert_before(
ActionDispatch::ParamsParser,
RedmineDmsf::NoParse, :urls => ["#{Redmine::Utils::relative_url_root}/dmsf/webdav"])