Skip to content

Commit

Permalink
From PR chrisroberts#63 in chrisroberts/dav4rack. Add support for PRO…
Browse files Browse the repository at this point in the history
…PFIND with empty request body.
  • Loading branch information
dabidski committed Nov 29, 2020
1 parent 07b172d commit 41860f6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/dav4rack/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def propfind
unless(resource.exist?)
NotFound
else
unless(request_document.xpath("//#{ns}propfind/#{ns}allprop").empty?)
if (request_document.children.empty? || !request_document.xpath("//#{ns}propfind/#{ns}allprop").empty?)
properties = resource.properties
else
check = request_document.xpath("//#{ns}propfind")
Expand Down
6 changes: 3 additions & 3 deletions lib/dav4rack/file_resource_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def explicit_locks(path, croot, args={})
end

def find_by_path(path, croot=nil)
lock = self.class.new(:path => path, :root => croot)
lock = self.new(:path => path, :root => croot)
lock.token.nil? ? nil : lock
end

Expand All @@ -43,8 +43,8 @@ def find_by_token(token, croot=nil)
struct = store.transaction(true){
store[:tokens][token]
}
if(tok)
self.class.new(:path => struct[:path], :root => croot)
if (token)
self.new(:path => struct[:path], :root => croot)
else
nil
end
Expand Down
3 changes: 2 additions & 1 deletion lib/dav4rack/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def initialize(public_path, path, request, response, options)
@options = options.dup
@max_timeout = options[:max_timeout] || 86400
@default_timeout = options[:default_timeout] || 60
@user = @options[:user] || request.ip
options[:user] ||= request.ip
@user = @options[:user]
setup if respond_to?(:setup)
public_methods(false).each do |method|
next if @skip_alias.include?(method.to_sym) || method[0,4] == 'DAV_' || method[0,5] == '_DAV_'
Expand Down
6 changes: 3 additions & 3 deletions lib/dav4rack/resources/file_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ def unlock(token)
if(token.nil? || token.empty?)
BadRequest
else
lock = FileResourceLock.find_by_token(token)
if(lock.nil? || lock.user_id != @user.id)
lock = FileResourceLock.find_by_token(token, root)
if(lock.nil? || lock.user != @user)
Forbidden
elsif(lock.path !~ /^#{Regexp.escape(@path)}.*$/)
Conflict
Expand Down Expand Up @@ -350,7 +350,7 @@ def authenticate(user, pass)
end

def root
@options[:root]
options[:root]
end

def file_path
Expand Down

0 comments on commit 41860f6

Please sign in to comment.