Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PROPFIND with empty request body #63

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions lib/dav4rack/file_resource_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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